mirror of https://github.com/databricks/cli.git
Update Go SDK to v0.19.0 (#729)
## Changes * Update Go SDK to v0.19.0 * Update commands per OpenAPI spec from Go SDK * Incorporate `client.Do()` signature change to include a (nil) header map * Update `workspace.WorkspaceService` mock with permissions methods * Skip `files` service in codegen; already implemented under the `fs` command ## Tests Unit and integration tests pass.
This commit is contained in:
parent
437263eb58
commit
1752e29885
|
@ -1 +1 @@
|
||||||
7b57ba3a53f4de3d049b6a24391fe5474212daf8
|
09a7fa63d9ae243e5407941f200960ca14d48b07
|
|
@ -2,7 +2,15 @@
|
||||||
|
|
||||||
package workspace
|
package workspace
|
||||||
|
|
||||||
{{ $excludes := list "command-execution" "statement-execution" "dbfs" "dbsql-permissions" "account-access-control-proxy" }}
|
{{ $excludes :=
|
||||||
|
list
|
||||||
|
"command-execution"
|
||||||
|
"statement-execution"
|
||||||
|
"dbfs"
|
||||||
|
"dbsql-permissions"
|
||||||
|
"account-access-control-proxy"
|
||||||
|
"files"
|
||||||
|
}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/databricks/cli/cmd/root"
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
|
|
@ -10,7 +10,15 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
{{ $excludes := list "command-execution" "statement-execution" "dbfs" "dbsql-permissions" "account-access-control-proxy" }}
|
{{ $excludes :=
|
||||||
|
list
|
||||||
|
"command-execution"
|
||||||
|
"statement-execution"
|
||||||
|
"dbfs"
|
||||||
|
"dbsql-permissions"
|
||||||
|
"account-access-control-proxy"
|
||||||
|
"files"
|
||||||
|
}}
|
||||||
|
|
||||||
{{if not (in $excludes .KebabName) }}
|
{{if not (in $excludes .KebabName) }}
|
||||||
{{template "service" .}}
|
{{template "service" .}}
|
||||||
|
|
|
@ -25,6 +25,7 @@ cmd/account/vpc-endpoints/vpc-endpoints.go linguist-generated=true
|
||||||
cmd/account/workspace-assignment/workspace-assignment.go linguist-generated=true
|
cmd/account/workspace-assignment/workspace-assignment.go linguist-generated=true
|
||||||
cmd/account/workspaces/workspaces.go linguist-generated=true
|
cmd/account/workspaces/workspaces.go linguist-generated=true
|
||||||
cmd/workspace/alerts/alerts.go linguist-generated=true
|
cmd/workspace/alerts/alerts.go linguist-generated=true
|
||||||
|
cmd/workspace/artifact-allowlists/artifact-allowlists.go linguist-generated=true
|
||||||
cmd/workspace/catalogs/catalogs.go linguist-generated=true
|
cmd/workspace/catalogs/catalogs.go linguist-generated=true
|
||||||
cmd/workspace/clean-rooms/clean-rooms.go linguist-generated=true
|
cmd/workspace/clean-rooms/clean-rooms.go linguist-generated=true
|
||||||
cmd/workspace/cluster-policies/cluster-policies.go linguist-generated=true
|
cmd/workspace/cluster-policies/cluster-policies.go linguist-generated=true
|
||||||
|
@ -32,6 +33,7 @@ cmd/workspace/clusters/clusters.go linguist-generated=true
|
||||||
cmd/workspace/cmd.go linguist-generated=true
|
cmd/workspace/cmd.go linguist-generated=true
|
||||||
cmd/workspace/connections/connections.go linguist-generated=true
|
cmd/workspace/connections/connections.go linguist-generated=true
|
||||||
cmd/workspace/current-user/current-user.go linguist-generated=true
|
cmd/workspace/current-user/current-user.go linguist-generated=true
|
||||||
|
cmd/workspace/dashboard-widgets/dashboard-widgets.go linguist-generated=true
|
||||||
cmd/workspace/dashboards/dashboards.go linguist-generated=true
|
cmd/workspace/dashboards/dashboards.go linguist-generated=true
|
||||||
cmd/workspace/data-sources/data-sources.go linguist-generated=true
|
cmd/workspace/data-sources/data-sources.go linguist-generated=true
|
||||||
cmd/workspace/experiments/experiments.go linguist-generated=true
|
cmd/workspace/experiments/experiments.go linguist-generated=true
|
||||||
|
@ -48,14 +50,17 @@ cmd/workspace/jobs/jobs.go linguist-generated=true
|
||||||
cmd/workspace/libraries/libraries.go linguist-generated=true
|
cmd/workspace/libraries/libraries.go linguist-generated=true
|
||||||
cmd/workspace/metastores/metastores.go linguist-generated=true
|
cmd/workspace/metastores/metastores.go linguist-generated=true
|
||||||
cmd/workspace/model-registry/model-registry.go linguist-generated=true
|
cmd/workspace/model-registry/model-registry.go linguist-generated=true
|
||||||
|
cmd/workspace/model-versions/model-versions.go linguist-generated=true
|
||||||
cmd/workspace/permissions/permissions.go linguist-generated=true
|
cmd/workspace/permissions/permissions.go linguist-generated=true
|
||||||
cmd/workspace/pipelines/pipelines.go linguist-generated=true
|
cmd/workspace/pipelines/pipelines.go linguist-generated=true
|
||||||
cmd/workspace/policy-families/policy-families.go linguist-generated=true
|
cmd/workspace/policy-families/policy-families.go linguist-generated=true
|
||||||
cmd/workspace/providers/providers.go linguist-generated=true
|
cmd/workspace/providers/providers.go linguist-generated=true
|
||||||
cmd/workspace/queries/queries.go linguist-generated=true
|
cmd/workspace/queries/queries.go linguist-generated=true
|
||||||
cmd/workspace/query-history/query-history.go linguist-generated=true
|
cmd/workspace/query-history/query-history.go linguist-generated=true
|
||||||
|
cmd/workspace/query-visualizations/query-visualizations.go linguist-generated=true
|
||||||
cmd/workspace/recipient-activation/recipient-activation.go linguist-generated=true
|
cmd/workspace/recipient-activation/recipient-activation.go linguist-generated=true
|
||||||
cmd/workspace/recipients/recipients.go linguist-generated=true
|
cmd/workspace/recipients/recipients.go linguist-generated=true
|
||||||
|
cmd/workspace/registered-models/registered-models.go linguist-generated=true
|
||||||
cmd/workspace/repos/repos.go linguist-generated=true
|
cmd/workspace/repos/repos.go linguist-generated=true
|
||||||
cmd/workspace/schemas/schemas.go linguist-generated=true
|
cmd/workspace/schemas/schemas.go linguist-generated=true
|
||||||
cmd/workspace/secrets/secrets.go linguist-generated=true
|
cmd/workspace/secrets/secrets.go linguist-generated=true
|
||||||
|
|
|
@ -55,6 +55,38 @@ func (MockWorkspaceService) Mkdirs(ctx context.Context, request workspace.Mkdirs
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPermissionLevels implements workspace.WorkspaceService.
|
||||||
|
func (MockWorkspaceService) GetPermissionLevels(
|
||||||
|
ctx context.Context,
|
||||||
|
request workspace.GetWorkspaceObjectPermissionLevelsRequest,
|
||||||
|
) (*workspace.GetWorkspaceObjectPermissionLevelsResponse, error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPermissions implements workspace.WorkspaceService.
|
||||||
|
func (MockWorkspaceService) GetPermissions(
|
||||||
|
ctx context.Context,
|
||||||
|
request workspace.GetWorkspaceObjectPermissionsRequest,
|
||||||
|
) (*workspace.WorkspaceObjectPermissions, error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPermissions implements workspace.WorkspaceService.
|
||||||
|
func (MockWorkspaceService) SetPermissions(
|
||||||
|
ctx context.Context,
|
||||||
|
request workspace.WorkspaceObjectPermissionsRequest,
|
||||||
|
) (*workspace.WorkspaceObjectPermissions, error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePermissions implements workspace.WorkspaceService.
|
||||||
|
func (MockWorkspaceService) UpdatePermissions(
|
||||||
|
ctx context.Context,
|
||||||
|
request workspace.WorkspaceObjectPermissionsRequest,
|
||||||
|
) (*workspace.WorkspaceObjectPermissions, error) {
|
||||||
|
panic("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
func TestUploadArtifactFileToCorrectRemotePath(t *testing.T) {
|
func TestUploadArtifactFileToCorrectRemotePath(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
whlPath := filepath.Join(dir, "dist", "test.whl")
|
whlPath := filepath.Join(dir, "dist", "test.whl")
|
||||||
|
|
|
@ -60,6 +60,7 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
cmd.Flags().BoolVar(&createReq.Confidential, "confidential", createReq.Confidential, `indicates if an oauth client-secret should be generated.`)
|
cmd.Flags().BoolVar(&createReq.Confidential, "confidential", createReq.Confidential, `indicates if an oauth client-secret should be generated.`)
|
||||||
|
// TODO: array: scopes
|
||||||
// TODO: complex arg: token_access_policy
|
// TODO: complex arg: token_access_policy
|
||||||
|
|
||||||
cmd.Use = "create"
|
cmd.Use = "create"
|
||||||
|
|
|
@ -368,7 +368,7 @@ func newPatch() *cobra.Command {
|
||||||
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: array: Operations
|
// TODO: array: Operations
|
||||||
// TODO: array: schema
|
// TODO: array: schemas
|
||||||
|
|
||||||
cmd.Use = "patch ID"
|
cmd.Use = "patch ID"
|
||||||
cmd.Short = `Update group details.`
|
cmd.Short = `Update group details.`
|
||||||
|
|
|
@ -34,22 +34,21 @@ func New() *cobra.Command {
|
||||||
|
|
||||||
1. **Create storage**: In AWS, [create a new AWS S3 bucket] with a specific
|
1. **Create storage**: In AWS, [create a new AWS S3 bucket] with a specific
|
||||||
bucket policy. Using Databricks APIs, call the Account API to create a
|
bucket policy. Using Databricks APIs, call the Account API to create a
|
||||||
[storage configuration object](#operation/create-storage-config) that uses the
|
[storage configuration object](:method:Storage/Create) that uses the bucket
|
||||||
bucket name. 2. **Create credentials**: In AWS, create the appropriate AWS IAM
|
name. 2. **Create credentials**: In AWS, create the appropriate AWS IAM role.
|
||||||
role. For full details, including the required IAM role policies and trust
|
For full details, including the required IAM role policies and trust
|
||||||
relationship, see [Billable usage log delivery]. Using Databricks APIs, call
|
relationship, see [Billable usage log delivery]. Using Databricks APIs, call
|
||||||
the Account API to create a [credential configuration
|
the Account API to create a [credential configuration
|
||||||
object](#operation/create-credential-config) that uses the IAM role's ARN. 3.
|
object](:method:Credentials/Create) that uses the IAM role"s ARN. 3. **Create
|
||||||
**Create log delivery configuration**: Using Databricks APIs, call the Account
|
log delivery configuration**: Using Databricks APIs, call the Account API to
|
||||||
API to [create a log delivery
|
[create a log delivery configuration](:method:LogDelivery/Create) that uses
|
||||||
configuration](#operation/create-log-delivery-config) that uses the credential
|
the credential and storage configuration objects from previous steps. You can
|
||||||
and storage configuration objects from previous steps. You can specify if the
|
specify if the logs should include all events of that log type in your account
|
||||||
logs should include all events of that log type in your account (_Account
|
(_Account level_ delivery) or only events for a specific set of workspaces
|
||||||
level_ delivery) or only events for a specific set of workspaces (_workspace
|
(_workspace level_ delivery). Account level log delivery applies to all
|
||||||
level_ delivery). Account level log delivery applies to all current and future
|
current and future workspaces plus account level logs, while workspace level
|
||||||
workspaces plus account level logs, while workspace level log delivery solely
|
log delivery solely delivers logs related to the specified workspaces. You can
|
||||||
delivers logs related to the specified workspaces. You can create multiple
|
create multiple types of delivery configurations per account.
|
||||||
types of delivery configurations per account.
|
|
||||||
|
|
||||||
For billable usage delivery: * For more information about billable usage logs,
|
For billable usage delivery: * For more information about billable usage logs,
|
||||||
see [Billable usage log delivery]. For the CSV schema, see the [Usage page]. *
|
see [Billable usage log delivery]. For the CSV schema, see the [Usage page]. *
|
||||||
|
@ -120,10 +119,9 @@ func newCreate() *cobra.Command {
|
||||||
|
|
||||||
Creates a new Databricks log delivery configuration to enable delivery of the
|
Creates a new Databricks log delivery configuration to enable delivery of the
|
||||||
specified type of logs to your storage location. This requires that you
|
specified type of logs to your storage location. This requires that you
|
||||||
already created a [credential object](#operation/create-credential-config)
|
already created a [credential object](:method:Credentials/Create) (which
|
||||||
(which encapsulates a cross-account service IAM role) and a [storage
|
encapsulates a cross-account service IAM role) and a [storage configuration
|
||||||
configuration object](#operation/create-storage-config) (which encapsulates an
|
object](:method:Storage/Create) (which encapsulates an S3 bucket).
|
||||||
S3 bucket).
|
|
||||||
|
|
||||||
For full details, including the required IAM role policies and bucket
|
For full details, including the required IAM role policies and bucket
|
||||||
policies, see [Deliver and access billable usage logs] or [Configure audit
|
policies, see [Deliver and access billable usage logs] or [Configure audit
|
||||||
|
@ -140,7 +138,7 @@ func newCreate() *cobra.Command {
|
||||||
|
|
||||||
You cannot delete a log delivery configuration, but you can disable it (see
|
You cannot delete a log delivery configuration, but you can disable it (see
|
||||||
[Enable or disable log delivery
|
[Enable or disable log delivery
|
||||||
configuration](#operation/patch-log-delivery-config-status)).
|
configuration](:method:LogDelivery/PatchStatus)).
|
||||||
|
|
||||||
[Configure audit logging]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html
|
[Configure audit logging]: https://docs.databricks.com/administration-guide/account-settings/audit-logs.html
|
||||||
[Deliver and access billable usage logs]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html`
|
[Deliver and access billable usage logs]: https://docs.databricks.com/administration-guide/account-settings/billable-usage-delivery.html`
|
||||||
|
@ -368,7 +366,7 @@ func newPatchStatus() *cobra.Command {
|
||||||
configurations is not supported, so disable log delivery configurations that
|
configurations is not supported, so disable log delivery configurations that
|
||||||
are no longer needed. Note that you can't re-enable a delivery configuration
|
are no longer needed. Note that you can't re-enable a delivery configuration
|
||||||
if this would violate the delivery configuration limits described under
|
if this would violate the delivery configuration limits described under
|
||||||
[Create log delivery](#operation/create-log-delivery-config).`
|
[Create log delivery](:method:LogDelivery/Create).`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ func newList() *cobra.Command {
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
response, err := a.Metastores.List(ctx)
|
response, err := a.Metastores.ListAll(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,7 +367,7 @@ func newPatch() *cobra.Command {
|
||||||
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: array: Operations
|
// TODO: array: Operations
|
||||||
// TODO: array: schema
|
// TODO: array: schemas
|
||||||
|
|
||||||
cmd.Use = "patch ID"
|
cmd.Use = "patch ID"
|
||||||
cmd.Short = `Update service principal details.`
|
cmd.Short = `Update service principal details.`
|
||||||
|
|
|
@ -375,7 +375,7 @@ func newPatch() *cobra.Command {
|
||||||
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: array: Operations
|
// TODO: array: Operations
|
||||||
// TODO: array: schema
|
// TODO: array: schemas
|
||||||
|
|
||||||
cmd.Use = "patch ID"
|
cmd.Use = "patch ID"
|
||||||
cmd.Short = `Update user details.`
|
cmd.Short = `Update user details.`
|
||||||
|
|
|
@ -70,7 +70,10 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Flags().StringVar(&createReq.Cloud, "cloud", createReq.Cloud, `The cloud provider which the workspace uses.`)
|
cmd.Flags().StringVar(&createReq.Cloud, "cloud", createReq.Cloud, `The cloud provider which the workspace uses.`)
|
||||||
// TODO: complex arg: cloud_resource_container
|
// TODO: complex arg: cloud_resource_container
|
||||||
cmd.Flags().StringVar(&createReq.CredentialsId, "credentials-id", createReq.CredentialsId, `ID of the workspace's credential configuration object.`)
|
cmd.Flags().StringVar(&createReq.CredentialsId, "credentials-id", createReq.CredentialsId, `ID of the workspace's credential configuration object.`)
|
||||||
|
// TODO: map via StringToStringVar: custom_tags
|
||||||
cmd.Flags().StringVar(&createReq.DeploymentName, "deployment-name", createReq.DeploymentName, `The deployment name defines part of the subdomain for the workspace.`)
|
cmd.Flags().StringVar(&createReq.DeploymentName, "deployment-name", createReq.DeploymentName, `The deployment name defines part of the subdomain for the workspace.`)
|
||||||
|
// TODO: complex arg: gcp_managed_network_config
|
||||||
|
// TODO: complex arg: gke_config
|
||||||
cmd.Flags().StringVar(&createReq.Location, "location", createReq.Location, `The Google Cloud region of the workspace data plane in your Google account.`)
|
cmd.Flags().StringVar(&createReq.Location, "location", createReq.Location, `The Google Cloud region of the workspace data plane in your Google account.`)
|
||||||
cmd.Flags().StringVar(&createReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", createReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`)
|
cmd.Flags().StringVar(&createReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", createReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`)
|
||||||
cmd.Flags().StringVar(&createReq.NetworkId, "network-id", createReq.NetworkId, ``)
|
cmd.Flags().StringVar(&createReq.NetworkId, "network-id", createReq.NetworkId, ``)
|
||||||
|
@ -391,6 +394,7 @@ func newUpdate() *cobra.Command {
|
||||||
cmd := &cobra.Command{}
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
var updateReq provisioning.UpdateWorkspaceRequest
|
var updateReq provisioning.UpdateWorkspaceRequest
|
||||||
|
var updateJson flags.JsonFlag
|
||||||
|
|
||||||
var updateSkipWait bool
|
var updateSkipWait bool
|
||||||
var updateTimeout time.Duration
|
var updateTimeout time.Duration
|
||||||
|
@ -398,9 +402,11 @@ func newUpdate() *cobra.Command {
|
||||||
cmd.Flags().BoolVar(&updateSkipWait, "no-wait", updateSkipWait, `do not wait to reach RUNNING state`)
|
cmd.Flags().BoolVar(&updateSkipWait, "no-wait", updateSkipWait, `do not wait to reach RUNNING state`)
|
||||||
cmd.Flags().DurationVar(&updateTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach RUNNING state`)
|
cmd.Flags().DurationVar(&updateTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach RUNNING state`)
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
cmd.Flags().StringVar(&updateReq.AwsRegion, "aws-region", updateReq.AwsRegion, `The AWS region of the workspace's data plane (for example, us-west-2).`)
|
cmd.Flags().StringVar(&updateReq.AwsRegion, "aws-region", updateReq.AwsRegion, `The AWS region of the workspace's data plane (for example, us-west-2).`)
|
||||||
cmd.Flags().StringVar(&updateReq.CredentialsId, "credentials-id", updateReq.CredentialsId, `ID of the workspace's credential configuration object.`)
|
cmd.Flags().StringVar(&updateReq.CredentialsId, "credentials-id", updateReq.CredentialsId, `ID of the workspace's credential configuration object.`)
|
||||||
|
// TODO: map via StringToStringVar: custom_tags
|
||||||
cmd.Flags().StringVar(&updateReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", updateReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`)
|
cmd.Flags().StringVar(&updateReq.ManagedServicesCustomerManagedKeyId, "managed-services-customer-managed-key-id", updateReq.ManagedServicesCustomerManagedKeyId, `The ID of the workspace's managed services encryption key configuration object.`)
|
||||||
cmd.Flags().StringVar(&updateReq.NetworkId, "network-id", updateReq.NetworkId, `The ID of the workspace's network configuration object.`)
|
cmd.Flags().StringVar(&updateReq.NetworkId, "network-id", updateReq.NetworkId, `The ID of the workspace's network configuration object.`)
|
||||||
cmd.Flags().StringVar(&updateReq.StorageConfigurationId, "storage-configuration-id", updateReq.StorageConfigurationId, `The ID of the workspace's storage configuration object.`)
|
cmd.Flags().StringVar(&updateReq.StorageConfigurationId, "storage-configuration-id", updateReq.StorageConfigurationId, `The ID of the workspace's storage configuration object.`)
|
||||||
|
@ -435,7 +441,8 @@ func newUpdate() *cobra.Command {
|
||||||
support. You can add or update the private access settings ID to upgrade a
|
support. You can add or update the private access settings ID to upgrade a
|
||||||
workspace to add support for front-end, back-end, or both types of
|
workspace to add support for front-end, back-end, or both types of
|
||||||
connectivity. You cannot remove (downgrade) any existing front-end or back-end
|
connectivity. You cannot remove (downgrade) any existing front-end or back-end
|
||||||
PrivateLink support on a workspace.
|
PrivateLink support on a workspace. - Custom tags. Given you provide an empty
|
||||||
|
custom tags, the update would not be applied.
|
||||||
|
|
||||||
After calling the PATCH operation to update the workspace configuration,
|
After calling the PATCH operation to update the workspace configuration,
|
||||||
make repeated GET requests with the workspace ID and check the workspace
|
make repeated GET requests with the workspace ID and check the workspace
|
||||||
|
@ -473,7 +480,8 @@ func newUpdate() *cobra.Command {
|
||||||
PrivateLink support. You can add or update the private access settings ID to
|
PrivateLink support. You can add or update the private access settings ID to
|
||||||
upgrade a workspace to add support for front-end, back-end, or both types of
|
upgrade a workspace to add support for front-end, back-end, or both types of
|
||||||
connectivity. You cannot remove (downgrade) any existing front-end or back-end
|
connectivity. You cannot remove (downgrade) any existing front-end or back-end
|
||||||
PrivateLink support on a workspace.
|
PrivateLink support on a workspace. - Custom tags. Given you provide an empty
|
||||||
|
custom tags, the update would not be applied.
|
||||||
|
|
||||||
**Important**: To update a running workspace, your workspace must have no
|
**Important**: To update a running workspace, your workspace must have no
|
||||||
running compute resources that run in your workspace's VPC in the Classic data
|
running compute resources that run in your workspace's VPC in the Classic data
|
||||||
|
@ -529,6 +537,12 @@ func newUpdate() *cobra.Command {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updateJson.Unmarshal(&updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down."
|
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down."
|
||||||
|
|
|
@ -60,7 +60,8 @@ func makeCommand(method string) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
var response any
|
var response any
|
||||||
err = api.Do(cmd.Context(), method, path, request, &response)
|
headers := map[string]string{"Content-Type": "application/json"}
|
||||||
|
err = api.Do(cmd.Context(), method, path, headers, request, &response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,172 @@
|
||||||
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
||||||
|
|
||||||
|
package artifact_allowlists
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var cmdOverrides []func(*cobra.Command)
|
||||||
|
|
||||||
|
func New() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "artifact-allowlists",
|
||||||
|
Short: `In Databricks Runtime 13.3 and above, you can add libraries and init scripts to the allowlist in UC so that users can leverage these artifacts on compute configured with shared access mode.`,
|
||||||
|
Long: `In Databricks Runtime 13.3 and above, you can add libraries and init scripts
|
||||||
|
to the allowlist in UC so that users can leverage these artifacts on compute
|
||||||
|
configured with shared access mode.`,
|
||||||
|
GroupID: "catalog",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"package": "catalog",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range cmdOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.GetArtifactAllowlistRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGet() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getReq catalog.GetArtifactAllowlistRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get ARTIFACT_TYPE"
|
||||||
|
cmd.Short = `Get an artifact allowlist.`
|
||||||
|
cmd.Long = `Get an artifact allowlist.
|
||||||
|
|
||||||
|
Get the artifact allowlist of a certain artifact type. The caller must be a
|
||||||
|
metastore admin.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
_, err = fmt.Sscan(args[0], &getReq.ArtifactType)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid ARTIFACT_TYPE: %s", args[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.ArtifactAllowlists.Get(ctx, getReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getOverrides {
|
||||||
|
fn(cmd, &getReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGet())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updateOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.SetArtifactAllowlist,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updateReq catalog.SetArtifactAllowlist
|
||||||
|
var updateJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Use = "update"
|
||||||
|
cmd.Short = `Set an artifact allowlist.`
|
||||||
|
cmd.Long = `Set an artifact allowlist.
|
||||||
|
|
||||||
|
Set the artifact allowlist of a certain artifact type. The whole artifact
|
||||||
|
allowlist is replaced with the new allowlist. The caller must be a metastore
|
||||||
|
admin.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updateJson.Unmarshal(&updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.ArtifactAllowlists.Update(ctx, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updateOverrides {
|
||||||
|
fn(cmd, &updateReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// end service ArtifactAllowlists
|
|
@ -60,6 +60,7 @@ func newCreate() *cobra.Command {
|
||||||
|
|
||||||
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`)
|
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`)
|
||||||
cmd.Flags().StringVar(&createReq.ConnectionName, "connection-name", createReq.ConnectionName, `The name of the connection to an external data source.`)
|
cmd.Flags().StringVar(&createReq.ConnectionName, "connection-name", createReq.ConnectionName, `The name of the connection to an external data source.`)
|
||||||
|
// TODO: map via StringToStringVar: options
|
||||||
// TODO: map via StringToStringVar: properties
|
// TODO: map via StringToStringVar: properties
|
||||||
cmd.Flags().StringVar(&createReq.ProviderName, "provider-name", createReq.ProviderName, `The name of delta sharing provider.`)
|
cmd.Flags().StringVar(&createReq.ProviderName, "provider-name", createReq.ProviderName, `The name of delta sharing provider.`)
|
||||||
cmd.Flags().StringVar(&createReq.ShareName, "share-name", createReq.ShareName, `The name of the share under the share provider.`)
|
cmd.Flags().StringVar(&createReq.ShareName, "share-name", createReq.ShareName, `The name of the share under the share provider.`)
|
||||||
|
@ -321,6 +322,7 @@ func newUpdate() *cobra.Command {
|
||||||
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`)
|
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`)
|
||||||
cmd.Flags().Var(&updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces.`)
|
cmd.Flags().Var(&updateReq.IsolationMode, "isolation-mode", `Whether the current securable is accessible from all workspaces or a specific set of workspaces.`)
|
||||||
cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `Name of catalog.`)
|
cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `Name of catalog.`)
|
||||||
|
// TODO: map via StringToStringVar: options
|
||||||
cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of catalog.`)
|
cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of catalog.`)
|
||||||
// TODO: map via StringToStringVar: properties
|
// TODO: map via StringToStringVar: properties
|
||||||
|
|
||||||
|
|
|
@ -318,8 +318,8 @@ func newGet() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Use = "get POLICY_ID"
|
cmd.Use = "get POLICY_ID"
|
||||||
cmd.Short = `Get entity.`
|
cmd.Short = `Get a cluster policy.`
|
||||||
cmd.Long = `Get entity.
|
cmd.Long = `Get a cluster policy.
|
||||||
|
|
||||||
Get a cluster policy entity. Creation and editing is available to admins only.`
|
Get a cluster policy entity. Creation and editing is available to admins only.`
|
||||||
|
|
||||||
|
@ -374,6 +374,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.GetClusterPolicyPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq compute.GetClusterPolicyPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels CLUSTER_POLICY_ID"
|
||||||
|
cmd.Short = `Get cluster policy permission levels.`
|
||||||
|
cmd.Long = `Get cluster policy permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||||
|
names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster policy for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.ClusterPolicyId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ClusterPolicies.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.GetClusterPolicyPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq compute.GetClusterPolicyPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions CLUSTER_POLICY_ID"
|
||||||
|
cmd.Short = `Get cluster policy permissions.`
|
||||||
|
cmd.Long = `Get cluster policy permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a cluster policy. Cluster policies can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||||
|
names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster policy for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.ClusterPolicyId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ClusterPolicies.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -396,8 +543,8 @@ func newList() *cobra.Command {
|
||||||
cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order in which the policies get listed.`)
|
cmd.Flags().Var(&listReq.SortOrder, "sort-order", `The order in which the policies get listed.`)
|
||||||
|
|
||||||
cmd.Use = "list"
|
cmd.Use = "list"
|
||||||
cmd.Short = `Get a cluster policy.`
|
cmd.Short = `List cluster policies.`
|
||||||
cmd.Long = `Get a cluster policy.
|
cmd.Long = `List cluster policies.
|
||||||
|
|
||||||
Returns a list of policies accessible by the requesting user.`
|
Returns a list of policies accessible by the requesting user.`
|
||||||
|
|
||||||
|
@ -449,4 +596,172 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.ClusterPolicyPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq compute.ClusterPolicyPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions CLUSTER_POLICY_ID"
|
||||||
|
cmd.Short = `Set cluster policy permissions.`
|
||||||
|
cmd.Long = `Set cluster policy permissions.
|
||||||
|
|
||||||
|
Sets permissions on a cluster policy. Cluster policies can inherit permissions
|
||||||
|
from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||||
|
names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster policy for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.ClusterPolicyId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ClusterPolicies.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.ClusterPolicyPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq compute.ClusterPolicyPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions CLUSTER_POLICY_ID"
|
||||||
|
cmd.Short = `Update cluster policy permissions.`
|
||||||
|
cmd.Long = `Update cluster policy permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a cluster policy. Cluster policies can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||||
|
names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster policy for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster policy for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.ClusterPolicyId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ClusterPolicies.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service ClusterPolicies
|
// end service ClusterPolicies
|
||||||
|
|
|
@ -169,6 +169,8 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Flags().StringVar(&createReq.ClusterName, "cluster-name", createReq.ClusterName, `Cluster name requested by the user.`)
|
cmd.Flags().StringVar(&createReq.ClusterName, "cluster-name", createReq.ClusterName, `Cluster name requested by the user.`)
|
||||||
cmd.Flags().Var(&createReq.ClusterSource, "cluster-source", `Determines whether the cluster was created by a user through the UI, created by the Databricks Jobs Scheduler, or through an API request.`)
|
cmd.Flags().Var(&createReq.ClusterSource, "cluster-source", `Determines whether the cluster was created by a user through the UI, created by the Databricks Jobs Scheduler, or through an API request.`)
|
||||||
// TODO: map via StringToStringVar: custom_tags
|
// TODO: map via StringToStringVar: custom_tags
|
||||||
|
cmd.Flags().Var(&createReq.DataSecurityMode, "data-security-mode", `This describes an enum.`)
|
||||||
|
// TODO: complex arg: docker_image
|
||||||
cmd.Flags().StringVar(&createReq.DriverInstancePoolId, "driver-instance-pool-id", createReq.DriverInstancePoolId, `The optional ID of the instance pool for the driver of the cluster belongs.`)
|
cmd.Flags().StringVar(&createReq.DriverInstancePoolId, "driver-instance-pool-id", createReq.DriverInstancePoolId, `The optional ID of the instance pool for the driver of the cluster belongs.`)
|
||||||
cmd.Flags().StringVar(&createReq.DriverNodeTypeId, "driver-node-type-id", createReq.DriverNodeTypeId, `The node type of the Spark driver.`)
|
cmd.Flags().StringVar(&createReq.DriverNodeTypeId, "driver-node-type-id", createReq.DriverNodeTypeId, `The node type of the Spark driver.`)
|
||||||
cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this cluster will dynamically acquire additional disk space when its Spark workers are running low on disk space.`)
|
cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this cluster will dynamically acquire additional disk space when its Spark workers are running low on disk space.`)
|
||||||
|
@ -180,6 +182,7 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Flags().IntVar(&createReq.NumWorkers, "num-workers", createReq.NumWorkers, `Number of worker nodes that this cluster should have.`)
|
cmd.Flags().IntVar(&createReq.NumWorkers, "num-workers", createReq.NumWorkers, `Number of worker nodes that this cluster should have.`)
|
||||||
cmd.Flags().StringVar(&createReq.PolicyId, "policy-id", createReq.PolicyId, `The ID of the cluster policy used to create the cluster if applicable.`)
|
cmd.Flags().StringVar(&createReq.PolicyId, "policy-id", createReq.PolicyId, `The ID of the cluster policy used to create the cluster if applicable.`)
|
||||||
cmd.Flags().Var(&createReq.RuntimeEngine, "runtime-engine", `Decides which runtime engine to be use, e.g.`)
|
cmd.Flags().Var(&createReq.RuntimeEngine, "runtime-engine", `Decides which runtime engine to be use, e.g.`)
|
||||||
|
cmd.Flags().StringVar(&createReq.SingleUserName, "single-user-name", createReq.SingleUserName, `Single user name if data_security_mode is SINGLE_USER.`)
|
||||||
// TODO: map via StringToStringVar: spark_conf
|
// TODO: map via StringToStringVar: spark_conf
|
||||||
// TODO: map via StringToStringVar: spark_env_vars
|
// TODO: map via StringToStringVar: spark_env_vars
|
||||||
// TODO: array: ssh_public_keys
|
// TODO: array: ssh_public_keys
|
||||||
|
@ -661,6 +664,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.GetClusterPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq compute.GetClusterPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels CLUSTER_ID"
|
||||||
|
cmd.Short = `Get cluster permission levels.`
|
||||||
|
cmd.Long = `Get cluster permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||||
|
names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.ClusterId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Clusters.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.GetClusterPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq compute.GetClusterPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions CLUSTER_ID"
|
||||||
|
cmd.Short = `Get cluster permissions.`
|
||||||
|
cmd.Long = `Get cluster permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a cluster. Clusters can inherit permissions from their
|
||||||
|
root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||||
|
names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.ClusterId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Clusters.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1217,6 +1367,90 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.ClusterPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq compute.ClusterPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions CLUSTER_ID"
|
||||||
|
cmd.Short = `Set cluster permissions.`
|
||||||
|
cmd.Long = `Set cluster permissions.
|
||||||
|
|
||||||
|
Sets permissions on a cluster. Clusters can inherit permissions from their
|
||||||
|
root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||||
|
names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.ClusterId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Clusters.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start spark-versions command
|
// start spark-versions command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1456,4 +1690,88 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.ClusterPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq compute.ClusterPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions CLUSTER_ID"
|
||||||
|
cmd.Short = `Update cluster permissions.`
|
||||||
|
cmd.Long = `Update cluster permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a cluster. Clusters can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||||
|
names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The cluster for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the cluster for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.ClusterId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Clusters.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Clusters
|
// end service Clusters
|
||||||
|
|
|
@ -4,12 +4,14 @@ package workspace
|
||||||
|
|
||||||
import (
|
import (
|
||||||
alerts "github.com/databricks/cli/cmd/workspace/alerts"
|
alerts "github.com/databricks/cli/cmd/workspace/alerts"
|
||||||
|
artifact_allowlists "github.com/databricks/cli/cmd/workspace/artifact-allowlists"
|
||||||
catalogs "github.com/databricks/cli/cmd/workspace/catalogs"
|
catalogs "github.com/databricks/cli/cmd/workspace/catalogs"
|
||||||
clean_rooms "github.com/databricks/cli/cmd/workspace/clean-rooms"
|
clean_rooms "github.com/databricks/cli/cmd/workspace/clean-rooms"
|
||||||
cluster_policies "github.com/databricks/cli/cmd/workspace/cluster-policies"
|
cluster_policies "github.com/databricks/cli/cmd/workspace/cluster-policies"
|
||||||
clusters "github.com/databricks/cli/cmd/workspace/clusters"
|
clusters "github.com/databricks/cli/cmd/workspace/clusters"
|
||||||
connections "github.com/databricks/cli/cmd/workspace/connections"
|
connections "github.com/databricks/cli/cmd/workspace/connections"
|
||||||
current_user "github.com/databricks/cli/cmd/workspace/current-user"
|
current_user "github.com/databricks/cli/cmd/workspace/current-user"
|
||||||
|
dashboard_widgets "github.com/databricks/cli/cmd/workspace/dashboard-widgets"
|
||||||
dashboards "github.com/databricks/cli/cmd/workspace/dashboards"
|
dashboards "github.com/databricks/cli/cmd/workspace/dashboards"
|
||||||
data_sources "github.com/databricks/cli/cmd/workspace/data-sources"
|
data_sources "github.com/databricks/cli/cmd/workspace/data-sources"
|
||||||
experiments "github.com/databricks/cli/cmd/workspace/experiments"
|
experiments "github.com/databricks/cli/cmd/workspace/experiments"
|
||||||
|
@ -26,14 +28,17 @@ import (
|
||||||
libraries "github.com/databricks/cli/cmd/workspace/libraries"
|
libraries "github.com/databricks/cli/cmd/workspace/libraries"
|
||||||
metastores "github.com/databricks/cli/cmd/workspace/metastores"
|
metastores "github.com/databricks/cli/cmd/workspace/metastores"
|
||||||
model_registry "github.com/databricks/cli/cmd/workspace/model-registry"
|
model_registry "github.com/databricks/cli/cmd/workspace/model-registry"
|
||||||
|
model_versions "github.com/databricks/cli/cmd/workspace/model-versions"
|
||||||
permissions "github.com/databricks/cli/cmd/workspace/permissions"
|
permissions "github.com/databricks/cli/cmd/workspace/permissions"
|
||||||
pipelines "github.com/databricks/cli/cmd/workspace/pipelines"
|
pipelines "github.com/databricks/cli/cmd/workspace/pipelines"
|
||||||
policy_families "github.com/databricks/cli/cmd/workspace/policy-families"
|
policy_families "github.com/databricks/cli/cmd/workspace/policy-families"
|
||||||
providers "github.com/databricks/cli/cmd/workspace/providers"
|
providers "github.com/databricks/cli/cmd/workspace/providers"
|
||||||
queries "github.com/databricks/cli/cmd/workspace/queries"
|
queries "github.com/databricks/cli/cmd/workspace/queries"
|
||||||
query_history "github.com/databricks/cli/cmd/workspace/query-history"
|
query_history "github.com/databricks/cli/cmd/workspace/query-history"
|
||||||
|
query_visualizations "github.com/databricks/cli/cmd/workspace/query-visualizations"
|
||||||
recipient_activation "github.com/databricks/cli/cmd/workspace/recipient-activation"
|
recipient_activation "github.com/databricks/cli/cmd/workspace/recipient-activation"
|
||||||
recipients "github.com/databricks/cli/cmd/workspace/recipients"
|
recipients "github.com/databricks/cli/cmd/workspace/recipients"
|
||||||
|
registered_models "github.com/databricks/cli/cmd/workspace/registered-models"
|
||||||
repos "github.com/databricks/cli/cmd/workspace/repos"
|
repos "github.com/databricks/cli/cmd/workspace/repos"
|
||||||
schemas "github.com/databricks/cli/cmd/workspace/schemas"
|
schemas "github.com/databricks/cli/cmd/workspace/schemas"
|
||||||
secrets "github.com/databricks/cli/cmd/workspace/secrets"
|
secrets "github.com/databricks/cli/cmd/workspace/secrets"
|
||||||
|
@ -59,12 +64,14 @@ func All() []*cobra.Command {
|
||||||
var out []*cobra.Command
|
var out []*cobra.Command
|
||||||
|
|
||||||
out = append(out, alerts.New())
|
out = append(out, alerts.New())
|
||||||
|
out = append(out, artifact_allowlists.New())
|
||||||
out = append(out, catalogs.New())
|
out = append(out, catalogs.New())
|
||||||
out = append(out, clean_rooms.New())
|
out = append(out, clean_rooms.New())
|
||||||
out = append(out, cluster_policies.New())
|
out = append(out, cluster_policies.New())
|
||||||
out = append(out, clusters.New())
|
out = append(out, clusters.New())
|
||||||
out = append(out, connections.New())
|
out = append(out, connections.New())
|
||||||
out = append(out, current_user.New())
|
out = append(out, current_user.New())
|
||||||
|
out = append(out, dashboard_widgets.New())
|
||||||
out = append(out, dashboards.New())
|
out = append(out, dashboards.New())
|
||||||
out = append(out, data_sources.New())
|
out = append(out, data_sources.New())
|
||||||
out = append(out, experiments.New())
|
out = append(out, experiments.New())
|
||||||
|
@ -81,14 +88,17 @@ func All() []*cobra.Command {
|
||||||
out = append(out, libraries.New())
|
out = append(out, libraries.New())
|
||||||
out = append(out, metastores.New())
|
out = append(out, metastores.New())
|
||||||
out = append(out, model_registry.New())
|
out = append(out, model_registry.New())
|
||||||
|
out = append(out, model_versions.New())
|
||||||
out = append(out, permissions.New())
|
out = append(out, permissions.New())
|
||||||
out = append(out, pipelines.New())
|
out = append(out, pipelines.New())
|
||||||
out = append(out, policy_families.New())
|
out = append(out, policy_families.New())
|
||||||
out = append(out, providers.New())
|
out = append(out, providers.New())
|
||||||
out = append(out, queries.New())
|
out = append(out, queries.New())
|
||||||
out = append(out, query_history.New())
|
out = append(out, query_history.New())
|
||||||
|
out = append(out, query_visualizations.New())
|
||||||
out = append(out, recipient_activation.New())
|
out = append(out, recipient_activation.New())
|
||||||
out = append(out, recipients.New())
|
out = append(out, recipients.New())
|
||||||
|
out = append(out, registered_models.New())
|
||||||
out = append(out, repos.New())
|
out = append(out, repos.New())
|
||||||
out = append(out, schemas.New())
|
out = append(out, schemas.New())
|
||||||
out = append(out, secrets.New())
|
out = append(out, secrets.New())
|
||||||
|
|
|
@ -65,7 +65,7 @@ func newCreate() *cobra.Command {
|
||||||
|
|
||||||
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`)
|
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`)
|
||||||
cmd.Flags().StringVar(&createReq.Owner, "owner", createReq.Owner, `Username of current owner of the connection.`)
|
cmd.Flags().StringVar(&createReq.Owner, "owner", createReq.Owner, `Username of current owner of the connection.`)
|
||||||
// TODO: map via StringToStringVar: properties_kvpairs
|
// TODO: map via StringToStringVar: properties
|
||||||
cmd.Flags().BoolVar(&createReq.ReadOnly, "read-only", createReq.ReadOnly, `If the connection is read only.`)
|
cmd.Flags().BoolVar(&createReq.ReadOnly, "read-only", createReq.ReadOnly, `If the connection is read only.`)
|
||||||
|
|
||||||
cmd.Use = "create"
|
cmd.Use = "create"
|
||||||
|
|
|
@ -0,0 +1,228 @@
|
||||||
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
||||||
|
|
||||||
|
package dashboard_widgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/sql"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var cmdOverrides []func(*cobra.Command)
|
||||||
|
|
||||||
|
func New() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "dashboard-widgets",
|
||||||
|
Short: `This is an evolving API that facilitates the addition and removal of widgets from existing dashboards within the Databricks Workspace.`,
|
||||||
|
Long: `This is an evolving API that facilitates the addition and removal of widgets
|
||||||
|
from existing dashboards within the Databricks Workspace. Data structures may
|
||||||
|
change over time.`,
|
||||||
|
GroupID: "sql",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"package": "sql",
|
||||||
|
},
|
||||||
|
|
||||||
|
// This service is being previewed; hide from help output.
|
||||||
|
Hidden: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range cmdOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// start create command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var createOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.CreateWidget,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newCreate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var createReq sql.CreateWidget
|
||||||
|
var createJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Use = "create"
|
||||||
|
cmd.Short = `Add widget to a dashboard.`
|
||||||
|
cmd.Long = `Add widget to a dashboard.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = createJson.Unmarshal(&createReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.DashboardWidgets.Create(ctx, createReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range createOverrides {
|
||||||
|
fn(cmd, &createReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newCreate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start delete command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var deleteOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.DeleteDashboardWidgetRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newDelete() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var deleteReq sql.DeleteDashboardWidgetRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "delete ID"
|
||||||
|
cmd.Short = `Remove widget.`
|
||||||
|
cmd.Long = `Remove widget.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
deleteReq.Id = args[0]
|
||||||
|
|
||||||
|
err = w.DashboardWidgets.Delete(ctx, deleteReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range deleteOverrides {
|
||||||
|
fn(cmd, &deleteReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newDelete())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updateOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.CreateWidget,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updateReq sql.CreateWidget
|
||||||
|
var updateJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Use = "update"
|
||||||
|
cmd.Short = `Update existing widget.`
|
||||||
|
cmd.Long = `Update existing widget.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updateJson.Unmarshal(&updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.DashboardWidgets.Update(ctx, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updateOverrides {
|
||||||
|
fn(cmd, &updateReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// end service DashboardWidgets
|
|
@ -58,14 +58,14 @@ func newCreate() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
cmd.Use = "create"
|
cmd.Use = "create NAME"
|
||||||
cmd.Short = `Create a dashboard object.`
|
cmd.Short = `Create a dashboard object.`
|
||||||
cmd.Long = `Create a dashboard object.`
|
cmd.Long = `Create a dashboard object.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := cobra.ExactArgs(0)
|
check := cobra.ExactArgs(1)
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
check = cobra.ExactArgs(0)
|
check = cobra.ExactArgs(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,6 +352,86 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start delete-runs command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var deleteRunsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.DeleteRuns,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newDeleteRuns() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var deleteRunsReq ml.DeleteRuns
|
||||||
|
var deleteRunsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&deleteRunsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Flags().IntVar(&deleteRunsReq.MaxRuns, "max-runs", deleteRunsReq.MaxRuns, `An optional positive integer indicating the maximum number of runs to delete.`)
|
||||||
|
|
||||||
|
cmd.Use = "delete-runs EXPERIMENT_ID MAX_TIMESTAMP_MILLIS"
|
||||||
|
cmd.Short = `Delete runs by creation time.`
|
||||||
|
cmd.Long = `Delete runs by creation time.
|
||||||
|
|
||||||
|
Bulk delete runs in an experiment that were created prior to or at the
|
||||||
|
specified timestamp. Deletes at most max_runs per request.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = deleteRunsJson.Unmarshal(&deleteRunsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deleteRunsReq.ExperimentId = args[0]
|
||||||
|
_, err = fmt.Sscan(args[1], &deleteRunsReq.MaxTimestampMillis)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid MAX_TIMESTAMP_MILLIS: %s", args[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.Experiments.DeleteRuns(ctx, deleteRunsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range deleteRunsOverrides {
|
||||||
|
fn(cmd, &deleteRunsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newDeleteRuns())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start delete-tag command
|
// start delete-tag command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -598,7 +678,7 @@ func newGetHistory() *cobra.Command {
|
||||||
|
|
||||||
getHistoryReq.MetricKey = args[0]
|
getHistoryReq.MetricKey = args[0]
|
||||||
|
|
||||||
response, err := w.Experiments.GetHistory(ctx, getHistoryReq)
|
response, err := w.Experiments.GetHistoryAll(ctx, getHistoryReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -623,6 +703,129 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.GetExperimentPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq ml.GetExperimentPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels EXPERIMENT_ID"
|
||||||
|
cmd.Short = `Get experiment permission levels.`
|
||||||
|
cmd.Long = `Get experiment permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionLevelsReq.ExperimentId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Experiments.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.GetExperimentPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq ml.GetExperimentPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions EXPERIMENT_ID"
|
||||||
|
cmd.Short = `Get experiment permissions.`
|
||||||
|
cmd.Long = `Get experiment permissions.
|
||||||
|
|
||||||
|
Gets the permissions of an experiment. Experiments can inherit permissions
|
||||||
|
from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionsReq.ExperimentId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Experiments.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start get-run command
|
// start get-run command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1428,6 +1631,86 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start restore-runs command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var restoreRunsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.RestoreRuns,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newRestoreRuns() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var restoreRunsReq ml.RestoreRuns
|
||||||
|
var restoreRunsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&restoreRunsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Flags().IntVar(&restoreRunsReq.MaxRuns, "max-runs", restoreRunsReq.MaxRuns, `An optional positive integer indicating the maximum number of runs to restore.`)
|
||||||
|
|
||||||
|
cmd.Use = "restore-runs EXPERIMENT_ID MIN_TIMESTAMP_MILLIS"
|
||||||
|
cmd.Short = `Restore runs by deletion time.`
|
||||||
|
cmd.Long = `Restore runs by deletion time.
|
||||||
|
|
||||||
|
Bulk restore runs in an experiment that were deleted no earlier than the
|
||||||
|
specified timestamp. Restores at most max_runs per request.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = restoreRunsJson.Unmarshal(&restoreRunsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
restoreRunsReq.ExperimentId = args[0]
|
||||||
|
_, err = fmt.Sscan(args[1], &restoreRunsReq.MinTimestampMillis)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid MIN_TIMESTAMP_MILLIS: %s", args[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.Experiments.RestoreRuns(ctx, restoreRunsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range restoreRunsOverrides {
|
||||||
|
fn(cmd, &restoreRunsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newRestoreRuns())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start search-experiments command
|
// start search-experiments command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1662,6 +1945,78 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.ExperimentPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq ml.ExperimentPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions EXPERIMENT_ID"
|
||||||
|
cmd.Short = `Set experiment permissions.`
|
||||||
|
cmd.Long = `Set experiment permissions.
|
||||||
|
|
||||||
|
Sets permissions on an experiment. Experiments can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPermissionsReq.ExperimentId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Experiments.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start set-tag command
|
// start set-tag command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1815,6 +2170,78 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.ExperimentPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq ml.ExperimentPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions EXPERIMENT_ID"
|
||||||
|
cmd.Short = `Update experiment permissions.`
|
||||||
|
cmd.Long = `Update experiment permissions.
|
||||||
|
|
||||||
|
Updates the permissions on an experiment. Experiments can inherit permissions
|
||||||
|
from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePermissionsReq.ExperimentId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Experiments.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start update-run command
|
// start update-run command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
|
|
@ -368,7 +368,7 @@ func newPatch() *cobra.Command {
|
||||||
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: array: Operations
|
// TODO: array: Operations
|
||||||
// TODO: array: schema
|
// TODO: array: schemas
|
||||||
|
|
||||||
cmd.Use = "patch ID"
|
cmd.Use = "patch ID"
|
||||||
cmd.Short = `Update group details.`
|
cmd.Short = `Update group details.`
|
||||||
|
|
|
@ -77,7 +77,6 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`)
|
cmd.Flags().BoolVar(&createReq.EnableElasticDisk, "enable-elastic-disk", createReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`)
|
||||||
// TODO: complex arg: gcp_attributes
|
// TODO: complex arg: gcp_attributes
|
||||||
cmd.Flags().IntVar(&createReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", createReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`)
|
cmd.Flags().IntVar(&createReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", createReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`)
|
||||||
// TODO: complex arg: instance_pool_fleet_attributes
|
|
||||||
cmd.Flags().IntVar(&createReq.MaxCapacity, "max-capacity", createReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`)
|
cmd.Flags().IntVar(&createReq.MaxCapacity, "max-capacity", createReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`)
|
||||||
cmd.Flags().IntVar(&createReq.MinIdleInstances, "min-idle-instances", createReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`)
|
cmd.Flags().IntVar(&createReq.MinIdleInstances, "min-idle-instances", createReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`)
|
||||||
// TODO: array: preloaded_docker_images
|
// TODO: array: preloaded_docker_images
|
||||||
|
@ -247,7 +246,6 @@ func newEdit() *cobra.Command {
|
||||||
cmd.Flags().BoolVar(&editReq.EnableElasticDisk, "enable-elastic-disk", editReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`)
|
cmd.Flags().BoolVar(&editReq.EnableElasticDisk, "enable-elastic-disk", editReq.EnableElasticDisk, `Autoscaling Local Storage: when enabled, this instances in this pool will dynamically acquire additional disk space when its Spark workers are running low on disk space.`)
|
||||||
// TODO: complex arg: gcp_attributes
|
// TODO: complex arg: gcp_attributes
|
||||||
cmd.Flags().IntVar(&editReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", editReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`)
|
cmd.Flags().IntVar(&editReq.IdleInstanceAutoterminationMinutes, "idle-instance-autotermination-minutes", editReq.IdleInstanceAutoterminationMinutes, `Automatically terminates the extra instances in the pool cache after they are inactive for this time in minutes if min_idle_instances requirement is already met.`)
|
||||||
// TODO: complex arg: instance_pool_fleet_attributes
|
|
||||||
cmd.Flags().IntVar(&editReq.MaxCapacity, "max-capacity", editReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`)
|
cmd.Flags().IntVar(&editReq.MaxCapacity, "max-capacity", editReq.MaxCapacity, `Maximum number of outstanding instances to keep in the pool, including both instances used by clusters and idle instances.`)
|
||||||
cmd.Flags().IntVar(&editReq.MinIdleInstances, "min-idle-instances", editReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`)
|
cmd.Flags().IntVar(&editReq.MinIdleInstances, "min-idle-instances", editReq.MinIdleInstances, `Minimum number of idle instances to keep in the instance pool.`)
|
||||||
// TODO: array: preloaded_docker_images
|
// TODO: array: preloaded_docker_images
|
||||||
|
@ -383,6 +381,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.GetInstancePoolPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq compute.GetInstancePoolPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels INSTANCE_POOL_ID"
|
||||||
|
cmd.Short = `Get instance pool permission levels.`
|
||||||
|
cmd.Long = `Get instance pool permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
|
||||||
|
names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx)
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the instance pool for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.InstancePoolId = args[0]
|
||||||
|
|
||||||
|
response, err := w.InstancePools.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.GetInstancePoolPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq compute.GetInstancePoolPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions INSTANCE_POOL_ID"
|
||||||
|
cmd.Short = `Get instance pool permissions.`
|
||||||
|
cmd.Long = `Get instance pool permissions.
|
||||||
|
|
||||||
|
Gets the permissions of an instance pool. Instance pools can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
|
||||||
|
names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx)
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the instance pool for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.InstancePoolId = args[0]
|
||||||
|
|
||||||
|
response, err := w.InstancePools.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -431,4 +576,172 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.InstancePoolPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq compute.InstancePoolPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions INSTANCE_POOL_ID"
|
||||||
|
cmd.Short = `Set instance pool permissions.`
|
||||||
|
cmd.Long = `Set instance pool permissions.
|
||||||
|
|
||||||
|
Sets permissions on an instance pool. Instance pools can inherit permissions
|
||||||
|
from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
|
||||||
|
names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx)
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the instance pool for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.InstancePoolId = args[0]
|
||||||
|
|
||||||
|
response, err := w.InstancePools.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*compute.InstancePoolPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq compute.InstancePoolPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions INSTANCE_POOL_ID"
|
||||||
|
cmd.Short = `Update instance pool permissions.`
|
||||||
|
cmd.Long = `Update instance pool permissions.
|
||||||
|
|
||||||
|
Updates the permissions on an instance pool. Instance pools can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
|
||||||
|
names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx)
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The instance pool for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the instance pool for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.InstancePoolId = args[0]
|
||||||
|
|
||||||
|
response, err := w.InstancePools.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service InstancePools
|
// end service InstancePools
|
||||||
|
|
|
@ -646,6 +646,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*jobs.GetJobPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq jobs.GetJobPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels JOB_ID"
|
||||||
|
cmd.Short = `Get job permission levels.`
|
||||||
|
cmd.Long = `Get job permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
|
||||||
|
names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The job for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the job for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.JobId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Jobs.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*jobs.GetJobPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq jobs.GetJobPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions JOB_ID"
|
||||||
|
cmd.Short = `Get job permissions.`
|
||||||
|
cmd.Long = `Get job permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a job. Jobs can inherit permissions from their root
|
||||||
|
object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
|
||||||
|
names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The job for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the job for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.JobId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Jobs.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start get-run command
|
// start get-run command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1285,6 +1432,90 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*jobs.JobPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq jobs.JobPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions JOB_ID"
|
||||||
|
cmd.Short = `Set job permissions.`
|
||||||
|
cmd.Long = `Set job permissions.
|
||||||
|
|
||||||
|
Sets permissions on a job. Jobs can inherit permissions from their root
|
||||||
|
object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
|
||||||
|
names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The job for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the job for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.JobId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Jobs.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start submit command
|
// start submit command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1484,4 +1715,88 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*jobs.JobPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq jobs.JobPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions JOB_ID"
|
||||||
|
cmd.Short = `Update job permissions.`
|
||||||
|
cmd.Long = `Update job permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a job. Jobs can inherit permissions from their root
|
||||||
|
object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
|
||||||
|
names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The job for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the job for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.JobId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Jobs.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Jobs
|
// end service Jobs
|
||||||
|
|
|
@ -154,7 +154,7 @@ func newClusterStatus() *cobra.Command {
|
||||||
|
|
||||||
clusterStatusReq.ClusterId = args[0]
|
clusterStatusReq.ClusterId = args[0]
|
||||||
|
|
||||||
response, err := w.Libraries.ClusterStatus(ctx, clusterStatusReq)
|
response, err := w.Libraries.ClusterStatusAll(ctx, clusterStatusReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1226,6 +1226,129 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.GetRegisteredModelPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq ml.GetRegisteredModelPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels REGISTERED_MODEL_ID"
|
||||||
|
cmd.Short = `Get registered model permission levels.`
|
||||||
|
cmd.Long = `Get registered model permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionLevelsReq.RegisteredModelId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ModelRegistry.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.GetRegisteredModelPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq ml.GetRegisteredModelPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions REGISTERED_MODEL_ID"
|
||||||
|
cmd.Short = `Get registered model permissions.`
|
||||||
|
cmd.Long = `Get registered model permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a registered model. Registered models can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionsReq.RegisteredModelId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ModelRegistry.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list-models command
|
// start list-models command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -1902,6 +2025,78 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.RegisteredModelPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq ml.RegisteredModelPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions REGISTERED_MODEL_ID"
|
||||||
|
cmd.Short = `Set registered model permissions.`
|
||||||
|
cmd.Long = `Set registered model permissions.
|
||||||
|
|
||||||
|
Sets permissions on a registered model. Registered models can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPermissionsReq.RegisteredModelId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ModelRegistry.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start test-registry-webhook command
|
// start test-registry-webhook command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -2292,6 +2487,78 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*ml.RegisteredModelPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq ml.RegisteredModelPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions REGISTERED_MODEL_ID"
|
||||||
|
cmd.Short = `Update registered model permissions.`
|
||||||
|
cmd.Long = `Update registered model permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a registered model. Registered models can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePermissionsReq.RegisteredModelId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ModelRegistry.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start update-webhook command
|
// start update-webhook command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
|
|
@ -0,0 +1,400 @@
|
||||||
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
||||||
|
|
||||||
|
package model_versions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var cmdOverrides []func(*cobra.Command)
|
||||||
|
|
||||||
|
func New() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "model-versions",
|
||||||
|
Short: `Databricks provides a hosted version of MLflow Model Registry in Unity Catalog.`,
|
||||||
|
Long: `Databricks provides a hosted version of MLflow Model Registry in Unity
|
||||||
|
Catalog. Models in Unity Catalog provide centralized access control, auditing,
|
||||||
|
lineage, and discovery of ML models across Databricks workspaces.
|
||||||
|
|
||||||
|
This API reference documents the REST endpoints for managing model versions in
|
||||||
|
Unity Catalog. For more details, see the [registered models API
|
||||||
|
docs](/api/workspace/registeredmodels).`,
|
||||||
|
GroupID: "catalog",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"package": "catalog",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range cmdOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// start delete command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var deleteOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.DeleteModelVersionRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newDelete() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var deleteReq catalog.DeleteModelVersionRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "delete FULL_NAME VERSION"
|
||||||
|
cmd.Short = `Delete a Model Version.`
|
||||||
|
cmd.Long = `Delete a Model Version.
|
||||||
|
|
||||||
|
Deletes a model version from the specified registered model. Any aliases
|
||||||
|
assigned to the model version will also be deleted.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of the parent registered
|
||||||
|
model. For the latter case, the caller must also be the owner or have the
|
||||||
|
**USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA**
|
||||||
|
privilege on the parent schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
deleteReq.FullName = args[0]
|
||||||
|
_, err = fmt.Sscan(args[1], &deleteReq.Version)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid VERSION: %s", args[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
err = w.ModelVersions.Delete(ctx, deleteReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range deleteOverrides {
|
||||||
|
fn(cmd, &deleteReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newDelete())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.GetModelVersionRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGet() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getReq catalog.GetModelVersionRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get FULL_NAME VERSION"
|
||||||
|
cmd.Short = `Get a Model Version.`
|
||||||
|
cmd.Long = `Get a Model Version.
|
||||||
|
|
||||||
|
Get a model version.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of (or have the **EXECUTE**
|
||||||
|
privilege on) the parent registered model. For the latter case, the caller
|
||||||
|
must also be the owner or have the **USE_CATALOG** privilege on the parent
|
||||||
|
catalog and the **USE_SCHEMA** privilege on the parent schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getReq.FullName = args[0]
|
||||||
|
_, err = fmt.Sscan(args[1], &getReq.Version)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid VERSION: %s", args[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.ModelVersions.Get(ctx, getReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getOverrides {
|
||||||
|
fn(cmd, &getReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGet())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-by-alias command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getByAliasOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.GetByAliasRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetByAlias() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getByAliasReq catalog.GetByAliasRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-by-alias FULL_NAME ALIAS"
|
||||||
|
cmd.Short = `Get Model Version By Alias.`
|
||||||
|
cmd.Long = `Get Model Version By Alias.
|
||||||
|
|
||||||
|
Get a model version by alias.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of (or have the **EXECUTE**
|
||||||
|
privilege on) the registered model. For the latter case, the caller must also
|
||||||
|
be the owner or have the **USE_CATALOG** privilege on the parent catalog and
|
||||||
|
the **USE_SCHEMA** privilege on the parent schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getByAliasReq.FullName = args[0]
|
||||||
|
getByAliasReq.Alias = args[1]
|
||||||
|
|
||||||
|
response, err := w.ModelVersions.GetByAlias(ctx, getByAliasReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getByAliasOverrides {
|
||||||
|
fn(cmd, &getByAliasReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetByAlias())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start list command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var listOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.ListModelVersionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newList() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var listReq catalog.ListModelVersionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Max number of model versions to return.`)
|
||||||
|
cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque token to send for the next page of results (pagination).`)
|
||||||
|
|
||||||
|
cmd.Use = "list FULL_NAME"
|
||||||
|
cmd.Short = `List Model Versions.`
|
||||||
|
cmd.Long = `List Model Versions.
|
||||||
|
|
||||||
|
List model versions. You can list model versions under a particular schema, or
|
||||||
|
list all model versions in the current metastore.
|
||||||
|
|
||||||
|
The returned models are filtered based on the privileges of the calling user.
|
||||||
|
For example, the metastore admin is able to list all the model versions. A
|
||||||
|
regular user needs to be the owner or have the **EXECUTE** privilege on the
|
||||||
|
parent registered model to recieve the model versions in the response. For the
|
||||||
|
latter case, the caller must also be the owner or have the **USE_CATALOG**
|
||||||
|
privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent
|
||||||
|
schema.
|
||||||
|
|
||||||
|
There is no guarantee of a specific ordering of the elements in the response.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
listReq.FullName = args[0]
|
||||||
|
|
||||||
|
response, err := w.ModelVersions.ListAll(ctx, listReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range listOverrides {
|
||||||
|
fn(cmd, &listReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newList())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updateOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.UpdateModelVersionRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updateReq catalog.UpdateModelVersionRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `The comment attached to the model version.`)
|
||||||
|
|
||||||
|
cmd.Use = "update FULL_NAME VERSION"
|
||||||
|
cmd.Short = `Update a Model Version.`
|
||||||
|
cmd.Long = `Update a Model Version.
|
||||||
|
|
||||||
|
Updates the specified model version.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of the parent registered
|
||||||
|
model. For the latter case, the caller must also be the owner or have the
|
||||||
|
**USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA**
|
||||||
|
privilege on the parent schema.
|
||||||
|
|
||||||
|
Currently only the comment of the model version can be updated.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
updateReq.FullName = args[0]
|
||||||
|
_, err = fmt.Sscan(args[1], &updateReq.Version)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid VERSION: %s", args[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.ModelVersions.Update(ctx, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updateOverrides {
|
||||||
|
fn(cmd, &updateReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// end service ModelVersions
|
|
@ -19,7 +19,52 @@ func New() *cobra.Command {
|
||||||
Use: "permissions",
|
Use: "permissions",
|
||||||
Short: `Permissions API are used to create read, write, edit, update and manage access for various users on different objects and endpoints.`,
|
Short: `Permissions API are used to create read, write, edit, update and manage access for various users on different objects and endpoints.`,
|
||||||
Long: `Permissions API are used to create read, write, edit, update and manage access
|
Long: `Permissions API are used to create read, write, edit, update and manage access
|
||||||
for various users on different objects and endpoints.`,
|
for various users on different objects and endpoints.
|
||||||
|
|
||||||
|
* **[Cluster permissions](:service:clusters)** — Manage which users can
|
||||||
|
manage, restart, or attach to clusters.
|
||||||
|
|
||||||
|
* **[Cluster policy permissions](:service:clusterpolicies)** — Manage which
|
||||||
|
users can use cluster policies.
|
||||||
|
|
||||||
|
* **[Delta Live Tables pipeline permissions](:service:pipelines)** — Manage
|
||||||
|
which users can view, manage, run, cancel, or own a Delta Live Tables
|
||||||
|
pipeline.
|
||||||
|
|
||||||
|
* **[Job permissions](:service:jobs)** — Manage which users can view,
|
||||||
|
manage, trigger, cancel, or own a job.
|
||||||
|
|
||||||
|
* **[MLflow experiment permissions](:service:experiments)** — Manage which
|
||||||
|
users can read, edit, or manage MLflow experiments.
|
||||||
|
|
||||||
|
* **[MLflow registered model permissions](:service:modelregistry)** — Manage
|
||||||
|
which users can read, edit, or manage MLflow registered models.
|
||||||
|
|
||||||
|
* **[Password permissions](:service:users)** — Manage which users can use
|
||||||
|
password login when SSO is enabled.
|
||||||
|
|
||||||
|
* **[Instance Pool permissions](:service:instancepools)** — Manage which
|
||||||
|
users can manage or attach to pools.
|
||||||
|
|
||||||
|
* **[Repo permissions](repos)** — Manage which users can read, run, edit, or
|
||||||
|
manage a repo.
|
||||||
|
|
||||||
|
* **[Serving endpoint permissions](:service:servingendpoints)** — Manage
|
||||||
|
which users can view, query, or manage a serving endpoint.
|
||||||
|
|
||||||
|
* **[SQL warehouse permissions](:service:warehouses)** — Manage which users
|
||||||
|
can use or manage SQL warehouses.
|
||||||
|
|
||||||
|
* **[Token permissions](:service:tokenmanagement)** — Manage which users can
|
||||||
|
create or use tokens.
|
||||||
|
|
||||||
|
* **[Workspace object permissions](:service:workspace)** — Manage which
|
||||||
|
users can read, run, edit, or manage directories, files, and notebooks.
|
||||||
|
|
||||||
|
For the mapping of the required permissions for specific actions or abilities
|
||||||
|
and other important information, see [Access Control].
|
||||||
|
|
||||||
|
[Access Control]: https://docs.databricks.com/security/auth-authz/access-control/index.html`,
|
||||||
GroupID: "iam",
|
GroupID: "iam",
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"package": "iam",
|
"package": "iam",
|
||||||
|
@ -54,8 +99,8 @@ func newGet() *cobra.Command {
|
||||||
cmd.Short = `Get object permissions.`
|
cmd.Short = `Get object permissions.`
|
||||||
cmd.Long = `Get object permissions.
|
cmd.Long = `Get object permissions.
|
||||||
|
|
||||||
Gets the permission of an object. Objects can inherit permissions from their
|
Gets the permissions of an object. Objects can inherit permissions from their
|
||||||
parent objects or root objects.`
|
parent objects or root object.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
@ -114,8 +159,8 @@ func newGetPermissionLevels() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Use = "get-permission-levels REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID"
|
cmd.Use = "get-permission-levels REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID"
|
||||||
cmd.Short = `Get permission levels.`
|
cmd.Short = `Get object permission levels.`
|
||||||
cmd.Long = `Get permission levels.
|
cmd.Long = `Get object permission levels.
|
||||||
|
|
||||||
Gets the permission levels that a user can have on an object.`
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
@ -180,11 +225,11 @@ func newSet() *cobra.Command {
|
||||||
// TODO: array: access_control_list
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
cmd.Use = "set REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID"
|
cmd.Use = "set REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID"
|
||||||
cmd.Short = `Set permissions.`
|
cmd.Short = `Set object permissions.`
|
||||||
cmd.Long = `Set permissions.
|
cmd.Long = `Set object permissions.
|
||||||
|
|
||||||
Sets permissions on object. Objects can inherit permissions from their parent
|
Sets permissions on an object. Objects can inherit permissions from their
|
||||||
objects and root objects.`
|
parent objects or root object.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
@ -207,11 +252,11 @@ func newSet() *cobra.Command {
|
||||||
setReq.RequestObjectType = args[0]
|
setReq.RequestObjectType = args[0]
|
||||||
setReq.RequestObjectId = args[1]
|
setReq.RequestObjectId = args[1]
|
||||||
|
|
||||||
err = w.Permissions.Set(ctx, setReq)
|
response, err := w.Permissions.Set(ctx, setReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return cmdio.Render(ctx, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable completions since they are not applicable.
|
// Disable completions since they are not applicable.
|
||||||
|
@ -253,10 +298,11 @@ func newUpdate() *cobra.Command {
|
||||||
// TODO: array: access_control_list
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
cmd.Use = "update REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID"
|
cmd.Use = "update REQUEST_OBJECT_TYPE REQUEST_OBJECT_ID"
|
||||||
cmd.Short = `Update permission.`
|
cmd.Short = `Update object permissions.`
|
||||||
cmd.Long = `Update permission.
|
cmd.Long = `Update object permissions.
|
||||||
|
|
||||||
Updates the permissions on an object.`
|
Updates the permissions on an object. Objects can inherit permissions from
|
||||||
|
their parent objects or root object.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
@ -279,11 +325,11 @@ func newUpdate() *cobra.Command {
|
||||||
updateReq.RequestObjectType = args[0]
|
updateReq.RequestObjectType = args[0]
|
||||||
updateReq.RequestObjectId = args[1]
|
updateReq.RequestObjectId = args[1]
|
||||||
|
|
||||||
err = w.Permissions.Update(ctx, updateReq)
|
response, err := w.Permissions.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return cmdio.Render(ctx, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable completions since they are not applicable.
|
// Disable completions since they are not applicable.
|
||||||
|
|
|
@ -272,6 +272,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*pipelines.GetPipelinePermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq pipelines.GetPipelinePermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels PIPELINE_ID"
|
||||||
|
cmd.Short = `Get pipeline permission levels.`
|
||||||
|
cmd.Long = `Get pipeline permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
|
||||||
|
names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The pipeline for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the pipeline for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.PipelineId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Pipelines.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*pipelines.GetPipelinePermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq pipelines.GetPipelinePermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions PIPELINE_ID"
|
||||||
|
cmd.Short = `Get pipeline permissions.`
|
||||||
|
cmd.Long = `Get pipeline permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a pipeline. Pipelines can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
|
||||||
|
names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The pipeline for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the pipeline for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.PipelineId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Pipelines.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start get-update command
|
// start get-update command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -664,6 +811,90 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*pipelines.PipelinePermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq pipelines.PipelinePermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions PIPELINE_ID"
|
||||||
|
cmd.Short = `Set pipeline permissions.`
|
||||||
|
cmd.Long = `Set pipeline permissions.
|
||||||
|
|
||||||
|
Sets permissions on a pipeline. Pipelines can inherit permissions from their
|
||||||
|
root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
|
||||||
|
names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The pipeline for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the pipeline for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.PipelineId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Pipelines.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start start-update command
|
// start start-update command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -942,4 +1173,88 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*pipelines.PipelinePermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq pipelines.PipelinePermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions PIPELINE_ID"
|
||||||
|
cmd.Short = `Update pipeline permissions.`
|
||||||
|
cmd.Long = `Update pipeline permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a pipeline. Pipelines can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
|
||||||
|
names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The pipeline for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the pipeline for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.PipelineId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Pipelines.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Pipelines
|
// end service Pipelines
|
||||||
|
|
|
@ -0,0 +1,236 @@
|
||||||
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
||||||
|
|
||||||
|
package query_visualizations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/sql"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var cmdOverrides []func(*cobra.Command)
|
||||||
|
|
||||||
|
func New() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "query-visualizations",
|
||||||
|
Short: `This is an evolving API that facilitates the addition and removal of vizualisations from existing queries within the Databricks Workspace.`,
|
||||||
|
Long: `This is an evolving API that facilitates the addition and removal of
|
||||||
|
vizualisations from existing queries within the Databricks Workspace. Data
|
||||||
|
structures may change over time.`,
|
||||||
|
GroupID: "sql",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"package": "sql",
|
||||||
|
},
|
||||||
|
|
||||||
|
// This service is being previewed; hide from help output.
|
||||||
|
Hidden: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range cmdOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// start create command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var createOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.CreateQueryVisualizationRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newCreate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var createReq sql.CreateQueryVisualizationRequest
|
||||||
|
var createJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Use = "create"
|
||||||
|
cmd.Short = `Add visualization to a query.`
|
||||||
|
cmd.Long = `Add visualization to a query.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = createJson.Unmarshal(&createReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.QueryVisualizations.Create(ctx, createReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range createOverrides {
|
||||||
|
fn(cmd, &createReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newCreate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start delete command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var deleteOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.DeleteQueryVisualizationRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newDelete() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var deleteReq sql.DeleteQueryVisualizationRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "delete ID"
|
||||||
|
cmd.Short = `Remove visualization.`
|
||||||
|
cmd.Long = `Remove visualization.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
deleteReq.Id = args[0]
|
||||||
|
|
||||||
|
err = w.QueryVisualizations.Delete(ctx, deleteReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range deleteOverrides {
|
||||||
|
fn(cmd, &deleteReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newDelete())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updateOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.Visualization,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updateReq sql.Visualization
|
||||||
|
var updateJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Use = "update ID"
|
||||||
|
cmd.Short = `Edit existing visualization.`
|
||||||
|
cmd.Long = `Edit existing visualization.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updateJson.Unmarshal(&updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.QueryVisualizations.Update(ctx, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updateOverrides {
|
||||||
|
fn(cmd, &updateReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// end service QueryVisualizations
|
|
@ -0,0 +1,635 @@
|
||||||
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
||||||
|
|
||||||
|
package registered_models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var cmdOverrides []func(*cobra.Command)
|
||||||
|
|
||||||
|
func New() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "registered-models",
|
||||||
|
Short: `Databricks provides a hosted version of MLflow Model Registry in Unity Catalog.`,
|
||||||
|
Long: `Databricks provides a hosted version of MLflow Model Registry in Unity
|
||||||
|
Catalog. Models in Unity Catalog provide centralized access control, auditing,
|
||||||
|
lineage, and discovery of ML models across Databricks workspaces.
|
||||||
|
|
||||||
|
An MLflow registered model resides in the third layer of Unity Catalog’s
|
||||||
|
three-level namespace. Registered models contain model versions, which
|
||||||
|
correspond to actual ML models (MLflow models). Creating new model versions
|
||||||
|
currently requires use of the MLflow Python client. Once model versions are
|
||||||
|
created, you can load them for batch inference using MLflow Python client
|
||||||
|
APIs, or deploy them for real-time serving using Databricks Model Serving.
|
||||||
|
|
||||||
|
All operations on registered models and model versions require USE_CATALOG
|
||||||
|
permissions on the enclosing catalog and USE_SCHEMA permissions on the
|
||||||
|
enclosing schema. In addition, the following additional privileges are
|
||||||
|
required for various operations:
|
||||||
|
|
||||||
|
* To create a registered model, users must additionally have the CREATE_MODEL
|
||||||
|
permission on the target schema. * To view registered model or model version
|
||||||
|
metadata, model version data files, or invoke a model version, users must
|
||||||
|
additionally have the EXECUTE permission on the registered model * To update
|
||||||
|
registered model or model version tags, users must additionally have APPLY TAG
|
||||||
|
permissions on the registered model * To update other registered model or
|
||||||
|
model version metadata (comments, aliases) create a new model version, or
|
||||||
|
update permissions on the registered model, users must be owners of the
|
||||||
|
registered model.
|
||||||
|
|
||||||
|
Note: The securable type for models is "FUNCTION". When using REST APIs (e.g.
|
||||||
|
tagging, grants) that specify a securable type, use "FUNCTION" as the
|
||||||
|
securable type.`,
|
||||||
|
GroupID: "catalog",
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"package": "catalog",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range cmdOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
// start create command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var createOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.CreateRegisteredModelRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newCreate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var createReq catalog.CreateRegisteredModelRequest
|
||||||
|
var createJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `The comment attached to the registered model.`)
|
||||||
|
cmd.Flags().StringVar(&createReq.StorageLocation, "storage-location", createReq.StorageLocation, `The storage location on the cloud under which model version data files are stored.`)
|
||||||
|
|
||||||
|
cmd.Use = "create CATALOG_NAME SCHEMA_NAME NAME"
|
||||||
|
cmd.Short = `Create a Registered Model.`
|
||||||
|
cmd.Long = `Create a Registered Model.
|
||||||
|
|
||||||
|
Creates a new registered model in Unity Catalog.
|
||||||
|
|
||||||
|
File storage for model versions in the registered model will be located in the
|
||||||
|
default location which is specified by the parent schema, or the parent
|
||||||
|
catalog, or the Metastore.
|
||||||
|
|
||||||
|
For registered model creation to succeed, the user must satisfy the following
|
||||||
|
conditions: - The caller must be a metastore admin, or be the owner of the
|
||||||
|
parent catalog and schema, or have the **USE_CATALOG** privilege on the parent
|
||||||
|
catalog and the **USE_SCHEMA** privilege on the parent schema. - The caller
|
||||||
|
must have the **CREATE MODEL** or **CREATE FUNCTION** privilege on the parent
|
||||||
|
schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(3)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = createJson.Unmarshal(&createReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
createReq.CatalogName = args[0]
|
||||||
|
createReq.SchemaName = args[1]
|
||||||
|
createReq.Name = args[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.RegisteredModels.Create(ctx, createReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range createOverrides {
|
||||||
|
fn(cmd, &createReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newCreate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start delete command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var deleteOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.DeleteRegisteredModelRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newDelete() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var deleteReq catalog.DeleteRegisteredModelRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "delete FULL_NAME"
|
||||||
|
cmd.Short = `Delete a Registered Model.`
|
||||||
|
cmd.Long = `Delete a Registered Model.
|
||||||
|
|
||||||
|
Deletes a registered model and all its model versions from the specified
|
||||||
|
parent catalog and schema.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of the registered model. For
|
||||||
|
the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
||||||
|
privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent
|
||||||
|
schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No FULL_NAME argument specified. Loading names for Registered Models drop-down."
|
||||||
|
names, err := w.RegisteredModels.RegisteredModelInfoNameToFullNameMap(ctx, catalog.ListRegisteredModelsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Registered Models drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The three-level (fully qualified) name of the registered model")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the three-level (fully qualified) name of the registered model")
|
||||||
|
}
|
||||||
|
deleteReq.FullName = args[0]
|
||||||
|
|
||||||
|
err = w.RegisteredModels.Delete(ctx, deleteReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range deleteOverrides {
|
||||||
|
fn(cmd, &deleteReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newDelete())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start delete-alias command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var deleteAliasOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.DeleteAliasRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newDeleteAlias() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var deleteAliasReq catalog.DeleteAliasRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "delete-alias FULL_NAME ALIAS"
|
||||||
|
cmd.Short = `Delete a Registered Model Alias.`
|
||||||
|
cmd.Long = `Delete a Registered Model Alias.
|
||||||
|
|
||||||
|
Deletes a registered model alias.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of the registered model. For
|
||||||
|
the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
||||||
|
privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent
|
||||||
|
schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
deleteAliasReq.FullName = args[0]
|
||||||
|
deleteAliasReq.Alias = args[1]
|
||||||
|
|
||||||
|
err = w.RegisteredModels.DeleteAlias(ctx, deleteAliasReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range deleteAliasOverrides {
|
||||||
|
fn(cmd, &deleteAliasReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newDeleteAlias())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.GetRegisteredModelRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGet() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getReq catalog.GetRegisteredModelRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get FULL_NAME"
|
||||||
|
cmd.Short = `Get a Registered Model.`
|
||||||
|
cmd.Long = `Get a Registered Model.
|
||||||
|
|
||||||
|
Get a registered model.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of (or have the **EXECUTE**
|
||||||
|
privilege on) the registered model. For the latter case, the caller must also
|
||||||
|
be the owner or have the **USE_CATALOG** privilege on the parent catalog and
|
||||||
|
the **USE_SCHEMA** privilege on the parent schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No FULL_NAME argument specified. Loading names for Registered Models drop-down."
|
||||||
|
names, err := w.RegisteredModels.RegisteredModelInfoNameToFullNameMap(ctx, catalog.ListRegisteredModelsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Registered Models drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The three-level (fully qualified) name of the registered model")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the three-level (fully qualified) name of the registered model")
|
||||||
|
}
|
||||||
|
getReq.FullName = args[0]
|
||||||
|
|
||||||
|
response, err := w.RegisteredModels.Get(ctx, getReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getOverrides {
|
||||||
|
fn(cmd, &getReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGet())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start list command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var listOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.ListRegisteredModelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newList() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var listReq catalog.ListRegisteredModelsRequest
|
||||||
|
var listJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&listJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Flags().StringVar(&listReq.CatalogName, "catalog-name", listReq.CatalogName, `The identifier of the catalog under which to list registered models.`)
|
||||||
|
cmd.Flags().IntVar(&listReq.MaxResults, "max-results", listReq.MaxResults, `Max number of registered models to return.`)
|
||||||
|
cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Opaque token to send for the next page of results (pagination).`)
|
||||||
|
cmd.Flags().StringVar(&listReq.SchemaName, "schema-name", listReq.SchemaName, `The identifier of the schema under which to list registered models.`)
|
||||||
|
|
||||||
|
cmd.Use = "list"
|
||||||
|
cmd.Short = `List Registered Models.`
|
||||||
|
cmd.Long = `List Registered Models.
|
||||||
|
|
||||||
|
List registered models. You can list registered models under a particular
|
||||||
|
schema, or list all registered models in the current metastore.
|
||||||
|
|
||||||
|
The returned models are filtered based on the privileges of the calling user.
|
||||||
|
For example, the metastore admin is able to list all the registered models. A
|
||||||
|
regular user needs to be the owner or have the **EXECUTE** privilege on the
|
||||||
|
registered model to recieve the registered models in the response. For the
|
||||||
|
latter case, the caller must also be the owner or have the **USE_CATALOG**
|
||||||
|
privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent
|
||||||
|
schema.
|
||||||
|
|
||||||
|
There is no guarantee of a specific ordering of the elements in the response.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(0)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = listJson.Unmarshal(&listReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.RegisteredModels.ListAll(ctx, listReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range listOverrides {
|
||||||
|
fn(cmd, &listReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newList())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start set-alias command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setAliasOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.SetRegisteredModelAliasRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetAlias() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setAliasReq catalog.SetRegisteredModelAliasRequest
|
||||||
|
var setAliasJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setAliasJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
cmd.Use = "set-alias FULL_NAME ALIAS VERSION_NUM"
|
||||||
|
cmd.Short = `Set a Registered Model Alias.`
|
||||||
|
cmd.Long = `Set a Registered Model Alias.
|
||||||
|
|
||||||
|
Set an alias on the specified registered model.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of the registered model. For
|
||||||
|
the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
||||||
|
privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent
|
||||||
|
schema.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(3)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setAliasJson.Unmarshal(&setAliasReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setAliasReq.FullName = args[0]
|
||||||
|
setAliasReq.Alias = args[1]
|
||||||
|
_, err = fmt.Sscan(args[2], &setAliasReq.VersionNum)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid VERSION_NUM: %s", args[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.RegisteredModels.SetAlias(ctx, setAliasReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setAliasOverrides {
|
||||||
|
fn(cmd, &setAliasReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetAlias())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updateOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*catalog.UpdateRegisteredModelRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdate() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updateReq catalog.UpdateRegisteredModelRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `The comment attached to the registered model.`)
|
||||||
|
cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name of the registered model.`)
|
||||||
|
cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `The identifier of the user who owns the registered model.`)
|
||||||
|
|
||||||
|
cmd.Use = "update FULL_NAME"
|
||||||
|
cmd.Short = `Update a Registered Model.`
|
||||||
|
cmd.Long = `Update a Registered Model.
|
||||||
|
|
||||||
|
Updates the specified registered model.
|
||||||
|
|
||||||
|
The caller must be a metastore admin or an owner of the registered model. For
|
||||||
|
the latter case, the caller must also be the owner or have the **USE_CATALOG**
|
||||||
|
privilege on the parent catalog and the **USE_SCHEMA** privilege on the parent
|
||||||
|
schema.
|
||||||
|
|
||||||
|
Currently only the name, the owner or the comment of the registered model can
|
||||||
|
be updated.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No FULL_NAME argument specified. Loading names for Registered Models drop-down."
|
||||||
|
names, err := w.RegisteredModels.RegisteredModelInfoNameToFullNameMap(ctx, catalog.ListRegisteredModelsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Registered Models drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The three-level (fully qualified) name of the registered model")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the three-level (fully qualified) name of the registered model")
|
||||||
|
}
|
||||||
|
updateReq.FullName = args[0]
|
||||||
|
|
||||||
|
response, err := w.RegisteredModels.Update(ctx, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updateOverrides {
|
||||||
|
fn(cmd, &updateReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdate())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// end service RegisteredModels
|
|
@ -275,6 +275,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.GetRepoPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq workspace.GetRepoPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels REPO_ID"
|
||||||
|
cmd.Short = `Get repo permission levels.`
|
||||||
|
cmd.Long = `Get repo permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
|
||||||
|
names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The repo for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the repo for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.RepoId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Repos.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.GetRepoPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq workspace.GetRepoPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions REPO_ID"
|
||||||
|
cmd.Short = `Get repo permissions.`
|
||||||
|
cmd.Long = `Get repo permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a repo. Repos can inherit permissions from their root
|
||||||
|
object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
|
||||||
|
names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The repo for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the repo for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.RepoId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Repos.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -351,6 +498,90 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.RepoPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq workspace.RepoPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions REPO_ID"
|
||||||
|
cmd.Short = `Set repo permissions.`
|
||||||
|
cmd.Long = `Set repo permissions.
|
||||||
|
|
||||||
|
Sets permissions on a repo. Repos can inherit permissions from their root
|
||||||
|
object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
|
||||||
|
names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The repo for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the repo for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.RepoId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Repos.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start update command
|
// start update command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -440,4 +671,88 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.RepoPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq workspace.RepoPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions REPO_ID"
|
||||||
|
cmd.Short = `Update repo permissions.`
|
||||||
|
cmd.Long = `Update repo permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a repo. Repos can inherit permissions from their
|
||||||
|
root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
|
||||||
|
names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The repo for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the repo for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.RepoId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Repos.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Repos
|
// end service Repos
|
||||||
|
|
|
@ -427,6 +427,79 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-secret command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getSecretOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.GetSecretRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetSecret() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getSecretReq workspace.GetSecretRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-secret SCOPE KEY"
|
||||||
|
cmd.Short = `Get a secret.`
|
||||||
|
cmd.Long = `Get a secret.
|
||||||
|
|
||||||
|
Gets the bytes representation of a secret value for the specified scope and
|
||||||
|
key.
|
||||||
|
|
||||||
|
Users need the READ permission to make this call.
|
||||||
|
|
||||||
|
Note that the secret value returned is in bytes. The interpretation of the
|
||||||
|
bytes is determined by the caller in DBUtils and the type the data is decoded
|
||||||
|
into.
|
||||||
|
|
||||||
|
Throws PERMISSION_DENIED if the user does not have permission to make this
|
||||||
|
API call. Throws RESOURCE_DOES_NOT_EXIST if no such secret or secret scope
|
||||||
|
exists.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getSecretReq.Scope = args[0]
|
||||||
|
getSecretReq.Key = args[1]
|
||||||
|
|
||||||
|
response, err := w.Secrets.GetSecret(ctx, getSecretReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getSecretOverrides {
|
||||||
|
fn(cmd, &getSecretReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetSecret())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list-acls command
|
// start list-acls command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
|
|
@ -367,7 +367,7 @@ func newPatch() *cobra.Command {
|
||||||
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: array: Operations
|
// TODO: array: Operations
|
||||||
// TODO: array: schema
|
// TODO: array: schemas
|
||||||
|
|
||||||
cmd.Use = "patch ID"
|
cmd.Use = "patch ID"
|
||||||
cmd.Short = `Update service principal details.`
|
cmd.Short = `Update service principal details.`
|
||||||
|
|
|
@ -374,6 +374,129 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*serving.GetServingEndpointPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq serving.GetServingEndpointPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels SERVING_ENDPOINT_ID"
|
||||||
|
cmd.Short = `Get serving endpoint permission levels.`
|
||||||
|
cmd.Long = `Get serving endpoint permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionLevelsReq.ServingEndpointId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ServingEndpoints.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*serving.GetServingEndpointPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq serving.GetServingEndpointPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions SERVING_ENDPOINT_ID"
|
||||||
|
cmd.Short = `Get serving endpoint permissions.`
|
||||||
|
cmd.Long = `Get serving endpoint permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a serving endpoint. Serving endpoints can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionsReq.ServingEndpointId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ServingEndpoints.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -542,6 +665,78 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*serving.ServingEndpointPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq serving.ServingEndpointPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions SERVING_ENDPOINT_ID"
|
||||||
|
cmd.Short = `Set serving endpoint permissions.`
|
||||||
|
cmd.Long = `Set serving endpoint permissions.
|
||||||
|
|
||||||
|
Sets permissions on a serving endpoint. Serving endpoints can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPermissionsReq.ServingEndpointId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ServingEndpoints.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start update-config command
|
// start update-config command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -630,4 +825,76 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*serving.ServingEndpointPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq serving.ServingEndpointPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions SERVING_ENDPOINT_ID"
|
||||||
|
cmd.Short = `Update serving endpoint permissions.`
|
||||||
|
cmd.Long = `Update serving endpoint permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a serving endpoint. Serving endpoints can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePermissionsReq.ServingEndpointId = args[0]
|
||||||
|
|
||||||
|
response, err := w.ServingEndpoints.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service ServingEndpoints
|
// end service ServingEndpoints
|
||||||
|
|
|
@ -262,6 +262,103 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels"
|
||||||
|
cmd.Short = `Get token permission levels.`
|
||||||
|
cmd.Long = `Get token permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
response, err := w.TokenManagement.GetPermissionLevels(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions"
|
||||||
|
cmd.Short = `Get token permissions.`
|
||||||
|
cmd.Long = `Get token permissions.
|
||||||
|
|
||||||
|
Gets the permissions of all tokens. Tokens can inherit permissions from their
|
||||||
|
root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
response, err := w.TokenManagement.GetPermissions(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -337,4 +434,154 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*settings.TokenPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq settings.TokenPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions"
|
||||||
|
cmd.Short = `Set token permissions.`
|
||||||
|
cmd.Long = `Set token permissions.
|
||||||
|
|
||||||
|
Sets permissions on all tokens. Tokens can inherit permissions from their root
|
||||||
|
object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(0)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.TokenManagement.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*settings.TokenPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq settings.TokenPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions"
|
||||||
|
cmd.Short = `Update token permissions.`
|
||||||
|
cmd.Long = `Update token permissions.
|
||||||
|
|
||||||
|
Updates the permissions on all tokens. Tokens can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(0)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.TokenManagement.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service TokenManagement
|
// end service TokenManagement
|
||||||
|
|
|
@ -276,6 +276,103 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels"
|
||||||
|
cmd.Short = `Get password permission levels.`
|
||||||
|
cmd.Long = `Get password permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
response, err := w.Users.GetPermissionLevels(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions"
|
||||||
|
cmd.Short = `Get password permissions.`
|
||||||
|
cmd.Long = `Get password permissions.
|
||||||
|
|
||||||
|
Gets the permissions of all passwords. Passwords can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
response, err := w.Users.GetPermissions(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start list command
|
// start list command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -375,7 +472,7 @@ func newPatch() *cobra.Command {
|
||||||
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: array: Operations
|
// TODO: array: Operations
|
||||||
// TODO: array: schema
|
// TODO: array: schemas
|
||||||
|
|
||||||
cmd.Use = "patch ID"
|
cmd.Use = "patch ID"
|
||||||
cmd.Short = `Update user details.`
|
cmd.Short = `Update user details.`
|
||||||
|
@ -441,6 +538,81 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*iam.PasswordPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq iam.PasswordPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions"
|
||||||
|
cmd.Short = `Set password permissions.`
|
||||||
|
cmd.Long = `Set password permissions.
|
||||||
|
|
||||||
|
Sets permissions on all passwords. Passwords can inherit permissions from
|
||||||
|
their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(0)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.Users.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start update command
|
// start update command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -534,4 +706,79 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*iam.PasswordPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq iam.PasswordPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions"
|
||||||
|
cmd.Short = `Update password permissions.`
|
||||||
|
cmd.Long = `Update password permissions.
|
||||||
|
|
||||||
|
Updates the permissions on all passwords. Passwords can inherit permissions
|
||||||
|
from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(0)
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
check = cobra.ExactArgs(0)
|
||||||
|
}
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := w.Users.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Users
|
// end service Users
|
||||||
|
|
|
@ -32,9 +32,6 @@ func New() *cobra.Command {
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"package": "catalog",
|
"package": "catalog",
|
||||||
},
|
},
|
||||||
|
|
||||||
// This service is being previewed; hide from help output.
|
|
||||||
Hidden: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply optional overrides to this command.
|
// Apply optional overrides to this command.
|
||||||
|
@ -66,7 +63,7 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `The comment attached to the volume.`)
|
cmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `The comment attached to the volume.`)
|
||||||
cmd.Flags().StringVar(&createReq.StorageLocation, "storage-location", createReq.StorageLocation, `The storage location on the cloud.`)
|
cmd.Flags().StringVar(&createReq.StorageLocation, "storage-location", createReq.StorageLocation, `The storage location on the cloud.`)
|
||||||
|
|
||||||
cmd.Use = "create CATALOG_NAME NAME SCHEMA_NAME VOLUME_TYPE"
|
cmd.Use = "create CATALOG_NAME SCHEMA_NAME NAME VOLUME_TYPE"
|
||||||
cmd.Short = `Create a Volume.`
|
cmd.Short = `Create a Volume.`
|
||||||
cmd.Long = `Create a Volume.
|
cmd.Long = `Create a Volume.
|
||||||
|
|
||||||
|
@ -111,8 +108,8 @@ func newCreate() *cobra.Command {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
createReq.CatalogName = args[0]
|
createReq.CatalogName = args[0]
|
||||||
createReq.Name = args[1]
|
createReq.SchemaName = args[1]
|
||||||
createReq.SchemaName = args[2]
|
createReq.Name = args[2]
|
||||||
_, err = fmt.Sscan(args[3], &createReq.VolumeType)
|
_, err = fmt.Sscan(args[3], &createReq.VolumeType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid VOLUME_TYPE: %s", args[3])
|
return fmt.Errorf("invalid VOLUME_TYPE: %s", args[3])
|
||||||
|
@ -253,6 +250,9 @@ func newList() *cobra.Command {
|
||||||
|
|
||||||
There is no guarantee of a specific ordering of the elements in the array.`
|
There is no guarantee of a specific ordering of the elements in the array.`
|
||||||
|
|
||||||
|
// This command is being previewed; hide from help output.
|
||||||
|
cmd.Hidden = true
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
|
@ -418,6 +418,153 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.GetWarehousePermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq sql.GetWarehousePermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels WAREHOUSE_ID"
|
||||||
|
cmd.Short = `Get SQL warehouse permission levels.`
|
||||||
|
cmd.Long = `Get SQL warehouse permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down."
|
||||||
|
names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The SQL warehouse for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the sql warehouse for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionLevelsReq.WarehouseId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Warehouses.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.GetWarehousePermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq sql.GetWarehousePermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions WAREHOUSE_ID"
|
||||||
|
cmd.Short = `Get SQL warehouse permissions.`
|
||||||
|
cmd.Long = `Get SQL warehouse permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a SQL warehouse. SQL warehouses can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down."
|
||||||
|
names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The SQL warehouse for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the sql warehouse for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
getPermissionsReq.WarehouseId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Warehouses.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start get-workspace-warehouse-config command
|
// start get-workspace-warehouse-config command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -541,6 +688,90 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.WarehousePermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq sql.WarehousePermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions WAREHOUSE_ID"
|
||||||
|
cmd.Short = `Set SQL warehouse permissions.`
|
||||||
|
cmd.Long = `Set SQL warehouse permissions.
|
||||||
|
|
||||||
|
Sets permissions on a SQL warehouse. SQL warehouses can inherit permissions
|
||||||
|
from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down."
|
||||||
|
names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The SQL warehouse for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the sql warehouse for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
setPermissionsReq.WarehouseId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Warehouses.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start set-workspace-warehouse-config command
|
// start set-workspace-warehouse-config command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -818,4 +1049,88 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*sql.WarehousePermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq sql.WarehousePermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions WAREHOUSE_ID"
|
||||||
|
cmd.Short = `Update SQL warehouse permissions.`
|
||||||
|
cmd.Long = `Update SQL warehouse permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a SQL warehouse. SQL warehouses can inherit
|
||||||
|
permissions from their root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No WAREHOUSE_ID argument specified. Loading names for Warehouses drop-down."
|
||||||
|
names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The SQL warehouse for which to get or manage permissions")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the sql warehouse for which to get or manage permissions")
|
||||||
|
}
|
||||||
|
updatePermissionsReq.WarehouseId = args[0]
|
||||||
|
|
||||||
|
response, err := w.Warehouses.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Warehouses
|
// end service Warehouses
|
||||||
|
|
|
@ -212,6 +212,131 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start get-permission-levels command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionLevelsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.GetWorkspaceObjectPermissionLevelsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissionLevels() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionLevelsReq workspace.GetWorkspaceObjectPermissionLevelsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permission-levels WORKSPACE_OBJECT_TYPE WORKSPACE_OBJECT_ID"
|
||||||
|
cmd.Short = `Get workspace object permission levels.`
|
||||||
|
cmd.Long = `Get workspace object permission levels.
|
||||||
|
|
||||||
|
Gets the permission levels that a user can have on an object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionLevelsReq.WorkspaceObjectType = args[0]
|
||||||
|
getPermissionLevelsReq.WorkspaceObjectId = args[1]
|
||||||
|
|
||||||
|
response, err := w.Workspace.GetPermissionLevels(ctx, getPermissionLevelsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionLevelsOverrides {
|
||||||
|
fn(cmd, &getPermissionLevelsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissionLevels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start get-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var getPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.GetWorkspaceObjectPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newGetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var getPermissionsReq workspace.GetWorkspaceObjectPermissionsRequest
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
|
||||||
|
cmd.Use = "get-permissions WORKSPACE_OBJECT_TYPE WORKSPACE_OBJECT_ID"
|
||||||
|
cmd.Short = `Get workspace object permissions.`
|
||||||
|
cmd.Long = `Get workspace object permissions.
|
||||||
|
|
||||||
|
Gets the permissions of a workspace object. Workspace objects can inherit
|
||||||
|
permissions from their parent objects or root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
getPermissionsReq.WorkspaceObjectType = args[0]
|
||||||
|
getPermissionsReq.WorkspaceObjectId = args[1]
|
||||||
|
|
||||||
|
response, err := w.Workspace.GetPermissions(ctx, getPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range getPermissionsOverrides {
|
||||||
|
fn(cmd, &getPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newGetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// start get-status command
|
// start get-status command
|
||||||
|
|
||||||
// Slice with functions to override default command behavior.
|
// Slice with functions to override default command behavior.
|
||||||
|
@ -507,4 +632,150 @@ func init() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start set-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var setPermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.WorkspaceObjectPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newSetPermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var setPermissionsReq workspace.WorkspaceObjectPermissionsRequest
|
||||||
|
var setPermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&setPermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "set-permissions WORKSPACE_OBJECT_TYPE WORKSPACE_OBJECT_ID"
|
||||||
|
cmd.Short = `Set workspace object permissions.`
|
||||||
|
cmd.Long = `Set workspace object permissions.
|
||||||
|
|
||||||
|
Sets permissions on a workspace object. Workspace objects can inherit
|
||||||
|
permissions from their parent objects or root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setPermissionsReq.WorkspaceObjectType = args[0]
|
||||||
|
setPermissionsReq.WorkspaceObjectId = args[1]
|
||||||
|
|
||||||
|
response, err := w.Workspace.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range setPermissionsOverrides {
|
||||||
|
fn(cmd, &setPermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newSetPermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// start update-permissions command
|
||||||
|
|
||||||
|
// Slice with functions to override default command behavior.
|
||||||
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
||||||
|
var updatePermissionsOverrides []func(
|
||||||
|
*cobra.Command,
|
||||||
|
*workspace.WorkspaceObjectPermissionsRequest,
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUpdatePermissions() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
|
var updatePermissionsReq workspace.WorkspaceObjectPermissionsRequest
|
||||||
|
var updatePermissionsJson flags.JsonFlag
|
||||||
|
|
||||||
|
// TODO: short flags
|
||||||
|
cmd.Flags().Var(&updatePermissionsJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
|
// TODO: array: access_control_list
|
||||||
|
|
||||||
|
cmd.Use = "update-permissions WORKSPACE_OBJECT_TYPE WORKSPACE_OBJECT_ID"
|
||||||
|
cmd.Short = `Update workspace object permissions.`
|
||||||
|
cmd.Long = `Update workspace object permissions.
|
||||||
|
|
||||||
|
Updates the permissions on a workspace object. Workspace objects can inherit
|
||||||
|
permissions from their parent objects or root object.`
|
||||||
|
|
||||||
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
check := cobra.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx := cmd.Context()
|
||||||
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePermissionsReq.WorkspaceObjectType = args[0]
|
||||||
|
updatePermissionsReq.WorkspaceObjectId = args[1]
|
||||||
|
|
||||||
|
response, err := w.Workspace.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cmdio.Render(ctx, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable completions since they are not applicable.
|
||||||
|
// Can be overridden by manual implementation in `override.go`.
|
||||||
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
||||||
|
|
||||||
|
// Apply optional overrides to this command.
|
||||||
|
for _, fn := range updatePermissionsOverrides {
|
||||||
|
fn(cmd, &updatePermissionsReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
||||||
|
cmd.AddCommand(newUpdatePermissions())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// end service Workspace
|
// end service Workspace
|
||||||
|
|
12
go.mod
12
go.mod
|
@ -4,7 +4,7 @@ go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/briandowns/spinner v1.23.0 // Apache 2.0
|
github.com/briandowns/spinner v1.23.0 // Apache 2.0
|
||||||
github.com/databricks/databricks-sdk-go v0.14.1 // Apache 2.0
|
github.com/databricks/databricks-sdk-go v0.19.0 // Apache 2.0
|
||||||
github.com/fatih/color v1.15.0 // MIT
|
github.com/fatih/color v1.15.0 // MIT
|
||||||
github.com/ghodss/yaml v1.0.0 // MIT + NOTICE
|
github.com/ghodss/yaml v1.0.0 // MIT + NOTICE
|
||||||
github.com/google/uuid v1.3.0 // BSD-3-Clause
|
github.com/google/uuid v1.3.0 // BSD-3-Clause
|
||||||
|
@ -32,7 +32,7 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/compute v1.20.1 // indirect
|
cloud.google.com/go/compute v1.23.0 // indirect
|
||||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||||
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
|
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||||
|
@ -42,7 +42,7 @@ require (
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
github.com/google/s2a-go v0.1.4 // indirect
|
github.com/google/s2a-go v0.1.5 // indirect
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
|
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
|
@ -54,10 +54,10 @@ require (
|
||||||
golang.org/x/net v0.14.0 // indirect
|
golang.org/x/net v0.14.0 // indirect
|
||||||
golang.org/x/sys v0.11.0 // indirect
|
golang.org/x/sys v0.11.0 // indirect
|
||||||
golang.org/x/time v0.3.0 // indirect
|
golang.org/x/time v0.3.0 // indirect
|
||||||
google.golang.org/api v0.131.0 // indirect
|
google.golang.org/api v0.138.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
|
||||||
google.golang.org/grpc v1.56.2 // indirect
|
google.golang.org/grpc v1.57.0 // indirect
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
|
24
go.sum
24
go.sum
|
@ -1,7 +1,7 @@
|
||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
cloud.google.com/go/compute v1.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZNbg=
|
cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY=
|
||||||
cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
|
cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
|
||||||
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
||||||
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
@ -36,8 +36,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
|
||||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/databricks/databricks-sdk-go v0.14.1 h1:s9x18c2i6XbJxem6zKdTrrwEUXQX/Nzn0iVM+qGlRus=
|
github.com/databricks/databricks-sdk-go v0.19.0 h1:Xh5A90/+8ehW7fTqoQbQK5xZu7a/akv3Xwv8UdWB4GU=
|
||||||
github.com/databricks/databricks-sdk-go v0.14.1/go.mod h1:0iuEtPIoD6oqw7OuFbPskhlEryt2FPH+Ies1UYiiDy8=
|
github.com/databricks/databricks-sdk-go v0.19.0/go.mod h1:Bt/3i3ry/rQdE6Y+psvkAENlp+LzJHaQK5PsLIstQb4=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
@ -93,8 +93,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc=
|
github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg=
|
||||||
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
|
github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
@ -257,8 +257,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/api v0.131.0 h1:AcgWS2edQ4chVEt/SxgDKubVu/9/idCJy00tBGuGB4M=
|
google.golang.org/api v0.138.0 h1:K/tVp05MxNVbHShRw9m7e9VJGdagNeTdMzqPH7AUqr0=
|
||||||
google.golang.org/api v0.131.0/go.mod h1:7vtkbKv2REjJbxmHSkBTBQ5LUGvPdAqjjvt84XAfhpA=
|
google.golang.org/api v0.138.0/go.mod h1:4xyob8CxC+0GChNBvEUAk8VBKNvYOTWM9T3v3UfRxuY=
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||||
|
@ -267,8 +267,8 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 h1:2FZP5XuJY9zQyGM5N0rtovnoXjiMUEIUMvw0m9wlpLc=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 h1:wukfNtZmZUurLN/atp2hiIeTKn7QJWIQdHzqmsOnAOk=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:8mL13HKkDa+IuJ8yruA3ci0q+0vsUz4m//+ottjwS5o=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
@ -277,8 +277,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
|
||||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||||
google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI=
|
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
|
||||||
google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
|
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
|
|
@ -112,6 +112,6 @@ func TestAccFsMkdirWhenFileExistsAtPath(t *testing.T) {
|
||||||
// assert run fails
|
// assert run fails
|
||||||
_, _, err = RequireErrorRun(t, "fs", "mkdir", "dbfs:"+path.Join(tmpDir, "hello"))
|
_, _, err = RequireErrorRun(t, "fs", "mkdir", "dbfs:"+path.Join(tmpDir, "hello"))
|
||||||
// Different cloud providers return different errors.
|
// Different cloud providers return different errors.
|
||||||
regex := regexp.MustCompile(`^Path is a file: .*$|^Cannot create directory .* because .* is an existing file\.$|^mkdirs\(hadoopPath: .*, permission: rwxrwxrwx\): failed$`)
|
regex := regexp.MustCompile(`(^|: )Path is a file: .*$|^Cannot create directory .* because .* is an existing file\.$|^mkdirs\(hadoopPath: .*, permission: rwxrwxrwx\): failed$`)
|
||||||
assert.Regexp(t, regex, err.Error())
|
assert.Regexp(t, regex, err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ func (a *syncTest) remoteFileContent(ctx context.Context, relativePath string, e
|
||||||
|
|
||||||
var res []byte
|
var res []byte
|
||||||
a.c.Eventually(func() bool {
|
a.c.Eventually(func() bool {
|
||||||
err = apiClient.Do(ctx, http.MethodGet, urlPath, nil, &res)
|
err = apiClient.Do(ctx, http.MethodGet, urlPath, nil, nil, &res)
|
||||||
require.NoError(a.t, err)
|
require.NoError(a.t, err)
|
||||||
actualContent := string(res)
|
actualContent := string(res)
|
||||||
return actualContent == expectedContent
|
return actualContent == expectedContent
|
||||||
|
|
|
@ -104,11 +104,8 @@ func (w *FilesClient) Write(ctx context.Context, name string, reader io.Reader,
|
||||||
|
|
||||||
overwrite := slices.Contains(mode, OverwriteIfExists)
|
overwrite := slices.Contains(mode, OverwriteIfExists)
|
||||||
urlPath = fmt.Sprintf("%s?overwrite=%t", urlPath, overwrite)
|
urlPath = fmt.Sprintf("%s?overwrite=%t", urlPath, overwrite)
|
||||||
err = w.apiClient.Do(ctx, http.MethodPut, urlPath, reader, nil,
|
headers := map[string]string{"Content-Type": "application/octet-stream"}
|
||||||
func(r *http.Request) error {
|
err = w.apiClient.Do(ctx, http.MethodPut, urlPath, headers, reader, nil)
|
||||||
r.Header.Set("Content-Type", "application/octet-stream")
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
// Return early on success.
|
// Return early on success.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -136,7 +133,7 @@ func (w *FilesClient) Read(ctx context.Context, name string) (io.ReadCloser, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err = w.apiClient.Do(ctx, http.MethodGet, urlPath, nil, &buf)
|
err = w.apiClient.Do(ctx, http.MethodGet, urlPath, nil, nil, &buf)
|
||||||
|
|
||||||
// Return early on success.
|
// Return early on success.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -168,7 +165,7 @@ func (w *FilesClient) Delete(ctx context.Context, name string, mode ...DeleteMod
|
||||||
return CannotDeleteRootError{}
|
return CannotDeleteRootError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = w.apiClient.Do(ctx, http.MethodDelete, urlPath, nil, nil)
|
err = w.apiClient.Do(ctx, http.MethodDelete, urlPath, nil, nil, nil)
|
||||||
|
|
||||||
// Return early on success.
|
// Return early on success.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -210,11 +207,7 @@ func (w *FilesClient) Stat(ctx context.Context, name string) (fs.FileInfo, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = w.apiClient.Do(ctx, http.MethodHead, urlPath, nil, nil,
|
err = w.apiClient.Do(ctx, http.MethodHead, urlPath, nil, nil, nil)
|
||||||
func(r *http.Request) error {
|
|
||||||
r.Header.Del("Content-Type")
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
// If the HEAD requests succeeds, the file exists.
|
// If the HEAD requests succeeds, the file exists.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = w.apiClient.Do(ctx, http.MethodPost, urlPath, body, nil)
|
err = w.apiClient.Do(ctx, http.MethodPost, urlPath, nil, body, nil)
|
||||||
|
|
||||||
// Return early on success.
|
// Return early on success.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in New Issue