From 3d28b189d6b21fbaac5a26a66de5447181328028 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:15:44 +0000 Subject: [PATCH 1/3] Bump github.com/databricks/databricks-sdk-go from 0.37.0 to 0.38.0 Bumps [github.com/databricks/databricks-sdk-go](https://github.com/databricks/databricks-sdk-go) from 0.37.0 to 0.38.0. - [Release notes](https://github.com/databricks/databricks-sdk-go/releases) - [Changelog](https://github.com/databricks/databricks-sdk-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/databricks/databricks-sdk-go/compare/v0.37.0...v0.38.0) --- updated-dependencies: - dependency-name: github.com/databricks/databricks-sdk-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6b9fc7a9d..4ba3076b0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/Masterminds/semver/v3 v3.2.1 // MIT github.com/briandowns/spinner v1.23.0 // Apache 2.0 - github.com/databricks/databricks-sdk-go v0.37.0 // Apache 2.0 + github.com/databricks/databricks-sdk-go v0.38.0 // Apache 2.0 github.com/fatih/color v1.16.0 // MIT github.com/ghodss/yaml v1.0.0 // MIT + NOTICE github.com/google/uuid v1.6.0 // BSD-3-Clause diff --git a/go.sum b/go.sum index c33ebe4c8..07137405f 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/databricks/databricks-sdk-go v0.37.0 h1:8ej3hNqfyfDNdV5YBjfLbq+p99JLu5NTtzwObbsIhRM= -github.com/databricks/databricks-sdk-go v0.37.0/go.mod h1:Yjy1gREDLK65g4axpVbVNKYAHYE2Sqzj0AB9QWHCBVM= +github.com/databricks/databricks-sdk-go v0.38.0 h1:MQhOCWTkdKItG+n6ZwcXQv9FWBVXq9fax8VSZns2e+0= +github.com/databricks/databricks-sdk-go v0.38.0/go.mod h1:Yjy1gREDLK65g4axpVbVNKYAHYE2Sqzj0AB9QWHCBVM= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 0dd577dd133e850ecf1ac82e6580a8dfa9f4abf8 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 15 Apr 2024 16:34:40 +0200 Subject: [PATCH 2/3] fixes --- .codegen/_openapi_sha | 2 +- .codegen/service.go.tmpl | 8 +- .gitattributes | 12 + bundle/config/mutator/override_compute.go | 4 +- .../config/mutator/override_compute_test.go | 4 +- bundle/schema/docs/bundle_descriptions.json | 174 +++-- .../workspace-assignment.go | 4 +- cmd/workspace/clusters/clusters.go | 2 + cmd/workspace/cmd.go | 24 + .../consumer-fulfillments.go | 162 +++++ .../consumer-installations.go | 369 +++++++++++ .../consumer-listings/consumer-listings.go | 263 ++++++++ .../consumer-personalization-requests.go | 237 +++++++ .../consumer-providers/consumer-providers.go | 173 +++++ .../lakehouse-monitors/lakehouse-monitors.go | 52 +- cmd/workspace/lakeview/lakeview.go | 6 - .../provider-exchange-filters.go | 305 +++++++++ .../provider-exchanges/provider-exchanges.go | 619 ++++++++++++++++++ .../provider-files/provider-files.go | 315 +++++++++ .../provider-listings/provider-listings.go | 375 +++++++++++ .../provider-personalization-requests.go | 187 ++++++ .../provider-provider-analytics-dashboards.go | 252 +++++++ .../provider-providers/provider-providers.go | 374 +++++++++++ 23 files changed, 3821 insertions(+), 102 deletions(-) create mode 100755 cmd/workspace/consumer-fulfillments/consumer-fulfillments.go create mode 100755 cmd/workspace/consumer-installations/consumer-installations.go create mode 100755 cmd/workspace/consumer-listings/consumer-listings.go create mode 100755 cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go create mode 100755 cmd/workspace/consumer-providers/consumer-providers.go create mode 100755 cmd/workspace/provider-exchange-filters/provider-exchange-filters.go create mode 100755 cmd/workspace/provider-exchanges/provider-exchanges.go create mode 100755 cmd/workspace/provider-files/provider-files.go create mode 100755 cmd/workspace/provider-listings/provider-listings.go create mode 100755 cmd/workspace/provider-personalization-requests/provider-personalization-requests.go create mode 100755 cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go create mode 100755 cmd/workspace/provider-providers/provider-providers.go diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 1d88bfb61..0aa4b1028 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -e316cc3d78d087522a74650e26586088da9ac8cb \ No newline at end of file +94684175b8bd65f8701f89729351f8069e8309c9 \ No newline at end of file diff --git a/.codegen/service.go.tmpl b/.codegen/service.go.tmpl index 4887a6230..6aabb02c9 100644 --- a/.codegen/service.go.tmpl +++ b/.codegen/service.go.tmpl @@ -145,7 +145,13 @@ func new{{.PascalName}}() *cobra.Command { {{- end}} {{end}} - {{- $excludeFromPrompts := list "workspace get-status" -}} + {{- $excludeFromPrompts := list + "workspace get-status" + "provider-exchanges get" + "provider-exchanges delete" + "provider-exchanges delete-listing-from-exchange" + "provider-exchanges list-exchanges-for-listing" + -}} {{- $fullCommandName := (print $serviceName " " .KebabName) -}} {{- $noPrompt := or .IsCrudCreate (in $excludeFromPrompts $fullCommandName) }} diff --git a/.gitattributes b/.gitattributes index c7d605130..f9aa02d18 100755 --- a/.gitattributes +++ b/.gitattributes @@ -38,6 +38,11 @@ cmd/workspace/cluster-policies/cluster-policies.go linguist-generated=true cmd/workspace/clusters/clusters.go linguist-generated=true cmd/workspace/cmd.go linguist-generated=true cmd/workspace/connections/connections.go linguist-generated=true +cmd/workspace/consumer-fulfillments/consumer-fulfillments.go linguist-generated=true +cmd/workspace/consumer-installations/consumer-installations.go linguist-generated=true +cmd/workspace/consumer-listings/consumer-listings.go linguist-generated=true +cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go linguist-generated=true +cmd/workspace/consumer-providers/consumer-providers.go linguist-generated=true cmd/workspace/credentials-manager/credentials-manager.go linguist-generated=true cmd/workspace/csp-enablement/csp-enablement.go linguist-generated=true cmd/workspace/current-user/current-user.go linguist-generated=true @@ -68,6 +73,13 @@ cmd/workspace/permission-migration/permission-migration.go linguist-generated=tr cmd/workspace/permissions/permissions.go linguist-generated=true cmd/workspace/pipelines/pipelines.go linguist-generated=true cmd/workspace/policy-families/policy-families.go linguist-generated=true +cmd/workspace/provider-exchange-filters/provider-exchange-filters.go linguist-generated=true +cmd/workspace/provider-exchanges/provider-exchanges.go linguist-generated=true +cmd/workspace/provider-files/provider-files.go linguist-generated=true +cmd/workspace/provider-listings/provider-listings.go linguist-generated=true +cmd/workspace/provider-personalization-requests/provider-personalization-requests.go linguist-generated=true +cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go linguist-generated=true +cmd/workspace/provider-providers/provider-providers.go linguist-generated=true cmd/workspace/providers/providers.go linguist-generated=true cmd/workspace/queries/queries.go linguist-generated=true cmd/workspace/query-history/query-history.go linguist-generated=true diff --git a/bundle/config/mutator/override_compute.go b/bundle/config/mutator/override_compute.go index 11a661123..73fbad364 100644 --- a/bundle/config/mutator/override_compute.go +++ b/bundle/config/mutator/override_compute.go @@ -28,10 +28,10 @@ func overrideJobCompute(j *resources.Job, compute string) { task = &task.ForEachTask.Task } - if task.NewCluster != nil || task.ExistingClusterId != "" || task.ComputeKey != "" || task.JobClusterKey != "" { + if task.NewCluster != nil || task.ExistingClusterId != "" || task.EnvironmentKey != "" || task.JobClusterKey != "" { task.NewCluster = nil task.JobClusterKey = "" - task.ComputeKey = "" + task.EnvironmentKey = "" task.ExistingClusterId = compute } } diff --git a/bundle/config/mutator/override_compute_test.go b/bundle/config/mutator/override_compute_test.go index 7c0e1cefa..152ee543e 100644 --- a/bundle/config/mutator/override_compute_test.go +++ b/bundle/config/mutator/override_compute_test.go @@ -36,7 +36,7 @@ func TestOverrideDevelopment(t *testing.T) { ExistingClusterId: "cluster2", }, { - ComputeKey: "compute_key", + EnvironmentKey: "environment_key", }, { JobClusterKey: "cluster_key", @@ -58,7 +58,7 @@ func TestOverrideDevelopment(t *testing.T) { assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[3].ExistingClusterId) assert.Nil(t, b.Config.Resources.Jobs["job1"].Tasks[0].NewCluster) - assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[2].ComputeKey) + assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[2].EnvironmentKey) assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[3].JobClusterKey) } diff --git a/bundle/schema/docs/bundle_descriptions.json b/bundle/schema/docs/bundle_descriptions.json index f1c887ae4..ca889ae52 100644 --- a/bundle/schema/docs/bundle_descriptions.json +++ b/bundle/schema/docs/bundle_descriptions.json @@ -38,6 +38,9 @@ "compute_id": { "description": "" }, + "databricks_cli_version": { + "description": "" + }, "deployment": { "description": "", "properties": { @@ -170,30 +173,11 @@ "additionalproperties": { "description": "", "properties": { - "compute": { - "description": "A list of compute requirements that can be referenced by tasks of this job.", - "items": { - "description": "", - "properties": { - "compute_key": { - "description": "A unique name for the compute requirement. This field is required and must be unique within the job.\n`JobTaskSettings` may refer to this field to determine the compute requirements for the task execution." - }, - "spec": { - "description": "", - "properties": { - "kind": { - "description": "The kind of compute described by this compute specification." - } - } - } - } - } - }, "continuous": { "description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.", "properties": { "pause_status": { - "description": "Whether this trigger is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." } } }, @@ -246,6 +230,31 @@ } } }, + "environments": { + "description": "A list of task execution environment specifications that can be referenced by tasks of this job.", + "items": { + "description": "", + "properties": { + "environment_key": { + "description": "The key of an environment. It has to be unique within a job." + }, + "spec": { + "description": "", + "properties": { + "client": { + "description": "*\nUser-friendly name for the client version: “client”: “1”\nThe version is a string, consisting of the major client version" + }, + "dependencies": { + "description": "List of pip dependencies, as supported by the version of pip in this environment.\nEach dependency is a pip requirement file line https://pip.pypa.io/en/stable/reference/requirements-file-format/\nAllowed dependency could be \u003crequirement specifier\u003e, \u003carchive url/path\u003e, \u003clocal project path\u003e(WSFS or Volumes in Databricks), \u003cvcs project url\u003e\nE.g. dependencies: [\"foo==0.0.1\", \"-r /Workspace/test/requirements.txt\"]", + "items": { + "description": "" + } + } + } + } + } + } + }, "format": { "description": "Used to tell what is the format of the job. This field is ignored in Create/Update/Reset calls. When using the Jobs API 2.1 this value is always set to `\"MULTI_TASK\"`." }, @@ -322,7 +331,7 @@ "description": "A unique name for the job cluster. This field is required and must be unique within the job.\n`JobTaskSettings` may refer to this field to determine which cluster to launch for the task execution." }, "new_cluster": { - "description": "If new_cluster, a description of a new cluster that is created for each run.", + "description": "If new_cluster, a description of a cluster that is created for each task.", "properties": { "apply_policy_default_values": { "description": "" @@ -401,6 +410,14 @@ } } }, + "clone_from": { + "description": "When specified, this clones libraries from a source cluster during the creation of a new cluster.", + "properties": { + "source_cluster_id": { + "description": "The cluster that is being cloned." + } + } + }, "cluster_log_conf": { "description": "The configuration for delivering spark logs to a long-term storage destination.\nTwo kinds of destinations (dbfs and s3) are supported. Only one destination can be specified\nfor one cluster. If the conf is given, the logs will be delivered to the destination every\n`5 mins`. The destination of driver logs is `$destination/$clusterId/driver`, while\nthe destination of executor logs is `$destination/$clusterId/executor`.", "properties": { @@ -725,7 +742,7 @@ "description": "An optional periodic schedule for this job. The default behavior is that the job only runs when triggered by clicking “Run Now” in the Jobs UI or sending an API request to `runNow`.", "properties": { "pause_status": { - "description": "Whether this trigger is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." }, "quartz_cron_expression": { "description": "A Cron expression using Quartz syntax that describes the schedule for a job. See [Cron Trigger](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html) for details. This field is required." @@ -746,9 +763,6 @@ "items": { "description": "", "properties": { - "compute_key": { - "description": "The key of the compute requirement, specified in `job.settings.compute`, to use for execution of this task." - }, "condition_task": { "description": "If condition_task, specifies a condition with an outcome that can be used to control the execution of other tasks. Does not require a cluster to execute and does not support retries or notifications.", "properties": { @@ -785,7 +799,7 @@ "description": "Optional schema to write to. This parameter is only used when a warehouse_id is also provided. If not provided, the `default` schema is used." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." }, "warehouse_id": { "description": "ID of the SQL warehouse to connect to. If provided, we automatically generate and provide the profile and connection details to dbt. It can be overridden on a per-command basis by using the `--profiles-dir` command line argument." @@ -844,6 +858,9 @@ } } }, + "environment_key": { + "description": "The key that references an environment spec in a job. This field is required for Python script, Python wheel and dbt tasks when using serverless compute." + }, "existing_cluster_id": { "description": "If existing_cluster_id, the ID of an existing cluster that is used for all runs.\nWhen running jobs or tasks on an existing cluster, you may need to manually restart\nthe cluster if it stops responding. We suggest running jobs and tasks on new clusters for\ngreater reliability" }, @@ -938,7 +955,7 @@ "description": "An optional minimal interval in milliseconds between the start of the failed run and the subsequent retry run. The default behavior is that unsuccessful runs are immediately retried." }, "new_cluster": { - "description": "If new_cluster, a description of a new cluster that is created for each run.", + "description": "If new_cluster, a description of a cluster that is created for each task.", "properties": { "apply_policy_default_values": { "description": "" @@ -1017,6 +1034,14 @@ } } }, + "clone_from": { + "description": "When specified, this clones libraries from a source cluster during the creation of a new cluster.", + "properties": { + "source_cluster_id": { + "description": "The cluster that is being cloned." + } + } + }, "cluster_log_conf": { "description": "The configuration for delivering spark logs to a long-term storage destination.\nTwo kinds of destinations (dbfs and s3) are supported. Only one destination can be specified\nfor one cluster. If the conf is given, the logs will be delivered to the destination every\n`5 mins`. The destination of driver logs is `$destination/$clusterId/driver`, while\nthe destination of executor logs is `$destination/$clusterId/executor`.", "properties": { @@ -1277,7 +1302,7 @@ "description": "The path of the notebook to be run in the Databricks workspace or remote repository.\nFor notebooks stored in the Databricks workspace, the path must be absolute and begin with a slash.\nFor notebooks stored in a remote repository, the path must be relative. This field is required." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." } } }, @@ -1429,7 +1454,7 @@ "description": "The Python file to be executed. Cloud file URIs (such as dbfs:/, s3:/, adls:/, gcs:/) and workspace paths are supported. For python files stored in the Databricks workspace, the path must be absolute and begin with `/`. For files stored in a remote repository, the path must be relative. This field is required." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." } } }, @@ -1507,7 +1532,7 @@ "description": "Path of the SQL file. Must be relative if the source is a remote Git repository and absolute for workspace paths." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." } } }, @@ -1609,7 +1634,7 @@ } }, "pause_status": { - "description": "Whether this trigger is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." }, "table": { "description": "", @@ -2649,6 +2674,9 @@ "compute_id": { "description": "" }, + "databricks_cli_version": { + "description": "" + }, "deployment": { "description": "", "properties": { @@ -2781,30 +2809,11 @@ "additionalproperties": { "description": "", "properties": { - "compute": { - "description": "A list of compute requirements that can be referenced by tasks of this job.", - "items": { - "description": "", - "properties": { - "compute_key": { - "description": "A unique name for the compute requirement. This field is required and must be unique within the job.\n`JobTaskSettings` may refer to this field to determine the compute requirements for the task execution." - }, - "spec": { - "description": "", - "properties": { - "kind": { - "description": "The kind of compute described by this compute specification." - } - } - } - } - } - }, "continuous": { "description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.", "properties": { "pause_status": { - "description": "Whether this trigger is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." } } }, @@ -2857,6 +2866,31 @@ } } }, + "environments": { + "description": "A list of task execution environment specifications that can be referenced by tasks of this job.", + "items": { + "description": "", + "properties": { + "environment_key": { + "description": "The key of an environment. It has to be unique within a job." + }, + "spec": { + "description": "", + "properties": { + "client": { + "description": "*\nUser-friendly name for the client version: “client”: “1”\nThe version is a string, consisting of the major client version" + }, + "dependencies": { + "description": "List of pip dependencies, as supported by the version of pip in this environment.\nEach dependency is a pip requirement file line https://pip.pypa.io/en/stable/reference/requirements-file-format/\nAllowed dependency could be \u003crequirement specifier\u003e, \u003carchive url/path\u003e, \u003clocal project path\u003e(WSFS or Volumes in Databricks), \u003cvcs project url\u003e\nE.g. dependencies: [\"foo==0.0.1\", \"-r /Workspace/test/requirements.txt\"]", + "items": { + "description": "" + } + } + } + } + } + } + }, "format": { "description": "Used to tell what is the format of the job. This field is ignored in Create/Update/Reset calls. When using the Jobs API 2.1 this value is always set to `\"MULTI_TASK\"`." }, @@ -2933,7 +2967,7 @@ "description": "A unique name for the job cluster. This field is required and must be unique within the job.\n`JobTaskSettings` may refer to this field to determine which cluster to launch for the task execution." }, "new_cluster": { - "description": "If new_cluster, a description of a new cluster that is created for each run.", + "description": "If new_cluster, a description of a cluster that is created for each task.", "properties": { "apply_policy_default_values": { "description": "" @@ -3012,6 +3046,14 @@ } } }, + "clone_from": { + "description": "When specified, this clones libraries from a source cluster during the creation of a new cluster.", + "properties": { + "source_cluster_id": { + "description": "The cluster that is being cloned." + } + } + }, "cluster_log_conf": { "description": "The configuration for delivering spark logs to a long-term storage destination.\nTwo kinds of destinations (dbfs and s3) are supported. Only one destination can be specified\nfor one cluster. If the conf is given, the logs will be delivered to the destination every\n`5 mins`. The destination of driver logs is `$destination/$clusterId/driver`, while\nthe destination of executor logs is `$destination/$clusterId/executor`.", "properties": { @@ -3336,7 +3378,7 @@ "description": "An optional periodic schedule for this job. The default behavior is that the job only runs when triggered by clicking “Run Now” in the Jobs UI or sending an API request to `runNow`.", "properties": { "pause_status": { - "description": "Whether this trigger is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." }, "quartz_cron_expression": { "description": "A Cron expression using Quartz syntax that describes the schedule for a job. See [Cron Trigger](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html) for details. This field is required." @@ -3357,9 +3399,6 @@ "items": { "description": "", "properties": { - "compute_key": { - "description": "The key of the compute requirement, specified in `job.settings.compute`, to use for execution of this task." - }, "condition_task": { "description": "If condition_task, specifies a condition with an outcome that can be used to control the execution of other tasks. Does not require a cluster to execute and does not support retries or notifications.", "properties": { @@ -3396,7 +3435,7 @@ "description": "Optional schema to write to. This parameter is only used when a warehouse_id is also provided. If not provided, the `default` schema is used." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." }, "warehouse_id": { "description": "ID of the SQL warehouse to connect to. If provided, we automatically generate and provide the profile and connection details to dbt. It can be overridden on a per-command basis by using the `--profiles-dir` command line argument." @@ -3455,6 +3494,9 @@ } } }, + "environment_key": { + "description": "The key that references an environment spec in a job. This field is required for Python script, Python wheel and dbt tasks when using serverless compute." + }, "existing_cluster_id": { "description": "If existing_cluster_id, the ID of an existing cluster that is used for all runs.\nWhen running jobs or tasks on an existing cluster, you may need to manually restart\nthe cluster if it stops responding. We suggest running jobs and tasks on new clusters for\ngreater reliability" }, @@ -3549,7 +3591,7 @@ "description": "An optional minimal interval in milliseconds between the start of the failed run and the subsequent retry run. The default behavior is that unsuccessful runs are immediately retried." }, "new_cluster": { - "description": "If new_cluster, a description of a new cluster that is created for each run.", + "description": "If new_cluster, a description of a cluster that is created for each task.", "properties": { "apply_policy_default_values": { "description": "" @@ -3628,6 +3670,14 @@ } } }, + "clone_from": { + "description": "When specified, this clones libraries from a source cluster during the creation of a new cluster.", + "properties": { + "source_cluster_id": { + "description": "The cluster that is being cloned." + } + } + }, "cluster_log_conf": { "description": "The configuration for delivering spark logs to a long-term storage destination.\nTwo kinds of destinations (dbfs and s3) are supported. Only one destination can be specified\nfor one cluster. If the conf is given, the logs will be delivered to the destination every\n`5 mins`. The destination of driver logs is `$destination/$clusterId/driver`, while\nthe destination of executor logs is `$destination/$clusterId/executor`.", "properties": { @@ -3888,7 +3938,7 @@ "description": "The path of the notebook to be run in the Databricks workspace or remote repository.\nFor notebooks stored in the Databricks workspace, the path must be absolute and begin with a slash.\nFor notebooks stored in a remote repository, the path must be relative. This field is required." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." } } }, @@ -4040,7 +4090,7 @@ "description": "The Python file to be executed. Cloud file URIs (such as dbfs:/, s3:/, adls:/, gcs:/) and workspace paths are supported. For python files stored in the Databricks workspace, the path must be absolute and begin with `/`. For files stored in a remote repository, the path must be relative. This field is required." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." } } }, @@ -4118,7 +4168,7 @@ "description": "Path of the SQL file. Must be relative if the source is a remote Git repository and absolute for workspace paths." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved from the local\nDatabricks workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a Databricks workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository." + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved from the local Databricks workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n* `WORKSPACE`: Notebook is located in Databricks workspace.\n* `GIT`: Notebook is located in cloud Git provider." } } }, @@ -4220,7 +4270,7 @@ } }, "pause_status": { - "description": "Whether this trigger is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." }, "table": { "description": "", diff --git a/cmd/account/workspace-assignment/workspace-assignment.go b/cmd/account/workspace-assignment/workspace-assignment.go index 935d64f05..b965d31ad 100755 --- a/cmd/account/workspace-assignment/workspace-assignment.go +++ b/cmd/account/workspace-assignment/workspace-assignment.go @@ -287,11 +287,11 @@ func newUpdate() *cobra.Command { return fmt.Errorf("invalid PRINCIPAL_ID: %s", args[1]) } - err = a.WorkspaceAssignment.Update(ctx, updateReq) + response, err := a.WorkspaceAssignment.Update(ctx, updateReq) if err != nil { return err } - return nil + return cmdio.Render(ctx, response) } // Disable completions since they are not applicable. diff --git a/cmd/workspace/clusters/clusters.go b/cmd/workspace/clusters/clusters.go index 70afc609b..e657fd9c3 100755 --- a/cmd/workspace/clusters/clusters.go +++ b/cmd/workspace/clusters/clusters.go @@ -193,6 +193,7 @@ func newCreate() *cobra.Command { cmd.Flags().IntVar(&createReq.AutoterminationMinutes, "autotermination-minutes", createReq.AutoterminationMinutes, `Automatically terminates the cluster after it is inactive for this time in minutes.`) // TODO: complex arg: aws_attributes // TODO: complex arg: azure_attributes + // TODO: complex arg: clone_from // TODO: complex arg: cluster_log_conf 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. Supported values: [ @@ -447,6 +448,7 @@ func newEdit() *cobra.Command { cmd.Flags().IntVar(&editReq.AutoterminationMinutes, "autotermination-minutes", editReq.AutoterminationMinutes, `Automatically terminates the cluster after it is inactive for this time in minutes.`) // TODO: complex arg: aws_attributes // TODO: complex arg: azure_attributes + // TODO: complex arg: clone_from // TODO: complex arg: cluster_log_conf cmd.Flags().StringVar(&editReq.ClusterName, "cluster-name", editReq.ClusterName, `Cluster name requested by the user.`) cmd.Flags().Var(&editReq.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. Supported values: [ diff --git a/cmd/workspace/cmd.go b/cmd/workspace/cmd.go index 8b0022dcc..a78b9bc1e 100755 --- a/cmd/workspace/cmd.go +++ b/cmd/workspace/cmd.go @@ -11,6 +11,11 @@ import ( cluster_policies "github.com/databricks/cli/cmd/workspace/cluster-policies" clusters "github.com/databricks/cli/cmd/workspace/clusters" connections "github.com/databricks/cli/cmd/workspace/connections" + consumer_fulfillments "github.com/databricks/cli/cmd/workspace/consumer-fulfillments" + consumer_installations "github.com/databricks/cli/cmd/workspace/consumer-installations" + consumer_listings "github.com/databricks/cli/cmd/workspace/consumer-listings" + consumer_personalization_requests "github.com/databricks/cli/cmd/workspace/consumer-personalization-requests" + consumer_providers "github.com/databricks/cli/cmd/workspace/consumer-providers" credentials_manager "github.com/databricks/cli/cmd/workspace/credentials-manager" current_user "github.com/databricks/cli/cmd/workspace/current-user" dashboard_widgets "github.com/databricks/cli/cmd/workspace/dashboard-widgets" @@ -38,6 +43,13 @@ import ( permissions "github.com/databricks/cli/cmd/workspace/permissions" pipelines "github.com/databricks/cli/cmd/workspace/pipelines" policy_families "github.com/databricks/cli/cmd/workspace/policy-families" + provider_exchange_filters "github.com/databricks/cli/cmd/workspace/provider-exchange-filters" + provider_exchanges "github.com/databricks/cli/cmd/workspace/provider-exchanges" + provider_files "github.com/databricks/cli/cmd/workspace/provider-files" + provider_listings "github.com/databricks/cli/cmd/workspace/provider-listings" + provider_personalization_requests "github.com/databricks/cli/cmd/workspace/provider-personalization-requests" + provider_provider_analytics_dashboards "github.com/databricks/cli/cmd/workspace/provider-provider-analytics-dashboards" + provider_providers "github.com/databricks/cli/cmd/workspace/provider-providers" providers "github.com/databricks/cli/cmd/workspace/providers" queries "github.com/databricks/cli/cmd/workspace/queries" query_history "github.com/databricks/cli/cmd/workspace/query-history" @@ -80,6 +92,11 @@ func All() []*cobra.Command { out = append(out, cluster_policies.New()) out = append(out, clusters.New()) out = append(out, connections.New()) + out = append(out, consumer_fulfillments.New()) + out = append(out, consumer_installations.New()) + out = append(out, consumer_listings.New()) + out = append(out, consumer_personalization_requests.New()) + out = append(out, consumer_providers.New()) out = append(out, credentials_manager.New()) out = append(out, current_user.New()) out = append(out, dashboard_widgets.New()) @@ -107,6 +124,13 @@ func All() []*cobra.Command { out = append(out, permissions.New()) out = append(out, pipelines.New()) out = append(out, policy_families.New()) + out = append(out, provider_exchange_filters.New()) + out = append(out, provider_exchanges.New()) + out = append(out, provider_files.New()) + out = append(out, provider_listings.New()) + out = append(out, provider_personalization_requests.New()) + out = append(out, provider_provider_analytics_dashboards.New()) + out = append(out, provider_providers.New()) out = append(out, providers.New()) out = append(out, queries.New()) out = append(out, query_history.New()) diff --git a/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go b/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go new file mode 100755 index 000000000..cd92002a4 --- /dev/null +++ b/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go @@ -0,0 +1,162 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package consumer_fulfillments + +import ( + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/databricks-sdk-go/service/marketplace" + "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: "consumer-fulfillments", + Short: `Fulfillments are entities that allow consumers to preview installations.`, + Long: `Fulfillments are entities that allow consumers to preview installations.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + + // 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, + *marketplace.GetListingContentMetadataRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetListingContentMetadataRequest + + // TODO: short flags + + cmd.Flags().IntVar(&getReq.PageSize, "page-size", getReq.PageSize, ``) + cmd.Flags().StringVar(&getReq.PageToken, "page-token", getReq.PageToken, ``) + + cmd.Use = "get LISTING_ID" + cmd.Short = `Get listing content metadata.` + cmd.Long = `Get listing content metadata. + + Get a high level preview of the metadata of listing installable content.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + getReq.ListingId = args[0] + + response := w.ConsumerFulfillments.Get(ctx, getReq) + return cmdio.RenderIterator(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 +} + +// 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, + *marketplace.ListFulfillmentsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListFulfillmentsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list LISTING_ID" + cmd.Short = `List all listing fulfillments.` + cmd.Long = `List all listing fulfillments. + + Get all listings fulfillments associated with a listing. A _fulfillment_ is a + potential installation. Standard installations contain metadata about the + attached share or git repo. Only one of these fields will be present. + Personalized installations contain metadata about the attached share or git + repo, as well as the Delta Sharing recipient type.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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.ListingId = args[0] + + response := w.ConsumerFulfillments.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// end service ConsumerFulfillments diff --git a/cmd/workspace/consumer-installations/consumer-installations.go b/cmd/workspace/consumer-installations/consumer-installations.go new file mode 100755 index 000000000..9d6c7c894 --- /dev/null +++ b/cmd/workspace/consumer-installations/consumer-installations.go @@ -0,0 +1,369 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package consumer_installations + +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/marketplace" + "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: "consumer-installations", + Short: `Installations are entities that allow consumers to interact with Databricks Marketplace listings.`, + Long: `Installations are entities that allow consumers to interact with Databricks + Marketplace listings.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newList()) + cmd.AddCommand(newListListingInstallations()) + cmd.AddCommand(newUpdate()) + + // 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, + *marketplace.CreateInstallationRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreateInstallationRequest + var createJson flags.JsonFlag + + // TODO: short flags + cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: complex arg: accepted_consumer_terms + cmd.Flags().StringVar(&createReq.CatalogName, "catalog-name", createReq.CatalogName, ``) + cmd.Flags().Var(&createReq.RecipientType, "recipient-type", `. Supported values: [DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS, DELTA_SHARING_RECIPIENT_TYPE_OPEN]`) + // TODO: complex arg: repo_detail + cmd.Flags().StringVar(&createReq.ShareName, "share-name", createReq.ShareName, ``) + + cmd.Use = "create LISTING_ID" + cmd.Short = `Install from a listing.` + cmd.Long = `Install from a listing. + + Install payload associated with a Databricks Marketplace listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = createJson.Unmarshal(&createReq) + if err != nil { + return err + } + } + createReq.ListingId = args[0] + + response, err := w.ConsumerInstallations.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 +} + +// 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, + *marketplace.DeleteInstallationRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq marketplace.DeleteInstallationRequest + + // TODO: short flags + + cmd.Use = "delete LISTING_ID INSTALLATION_ID" + cmd.Short = `Uninstall from a listing.` + cmd.Long = `Uninstall from a listing. + + Uninstall an installation associated with a Databricks Marketplace listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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.ListingId = args[0] + deleteReq.InstallationId = args[1] + + err = w.ConsumerInstallations.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 +} + +// 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, + *marketplace.ListAllInstallationsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListAllInstallationsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List all installations.` + cmd.Long = `List all installations. + + List all installations across all listings.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ConsumerInstallations.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// start list-listing-installations 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 listListingInstallationsOverrides []func( + *cobra.Command, + *marketplace.ListInstallationsRequest, +) + +func newListListingInstallations() *cobra.Command { + cmd := &cobra.Command{} + + var listListingInstallationsReq marketplace.ListInstallationsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listListingInstallationsReq.PageSize, "page-size", listListingInstallationsReq.PageSize, ``) + cmd.Flags().StringVar(&listListingInstallationsReq.PageToken, "page-token", listListingInstallationsReq.PageToken, ``) + + cmd.Use = "list-listing-installations LISTING_ID" + cmd.Short = `List installations for a listing.` + cmd.Long = `List installations for a listing. + + List all installations for a particular listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + listListingInstallationsReq.ListingId = args[0] + + response := w.ConsumerInstallations.ListListingInstallations(ctx, listListingInstallationsReq) + return cmdio.RenderIterator(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 listListingInstallationsOverrides { + fn(cmd, &listListingInstallationsReq) + } + + return cmd +} + +// 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, + *marketplace.UpdateInstallationRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdateInstallationRequest + 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.Flags().BoolVar(&updateReq.RotateToken, "rotate-token", updateReq.RotateToken, ``) + + cmd.Use = "update LISTING_ID INSTALLATION_ID" + cmd.Short = `Update an installation.` + cmd.Long = `Update an installation. + + This is a update API that will update the part of the fields defined in the + installation table as well as interact with external services according to the + fields not included in the installation table 1. the token will be rotate if + the rotateToken flag is true 2. the token will be forcibly rotate if the + rotateToken flag is true and the tokenInfo field is empty` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + updateReq.ListingId = args[0] + updateReq.InstallationId = args[1] + + response, err := w.ConsumerInstallations.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 +} + +// end service ConsumerInstallations diff --git a/cmd/workspace/consumer-listings/consumer-listings.go b/cmd/workspace/consumer-listings/consumer-listings.go new file mode 100755 index 000000000..70295dfb3 --- /dev/null +++ b/cmd/workspace/consumer-listings/consumer-listings.go @@ -0,0 +1,263 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package consumer_listings + +import ( + "fmt" + + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/databricks-sdk-go/service/marketplace" + "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: "consumer-listings", + Short: `Listings are the core entities in the Marketplace.`, + Long: `Listings are the core entities in the Marketplace. They represent the products + that are available for consumption.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + cmd.AddCommand(newSearch()) + + // 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, + *marketplace.GetListingRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetListingRequest + + // TODO: short flags + + cmd.Use = "get ID" + cmd.Short = `Get listing.` + cmd.Long = `Get listing. + + Get a published listing in the Databricks Marketplace that the consumer has + access to.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Consumer Listings drop-down." + names, err := w.ConsumerListings.ListingSummaryNameToIdMap(ctx, marketplace.ListListingsRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Consumer Listings drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + getReq.Id = args[0] + + response, err := w.ConsumerListings.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 +} + +// 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, + *marketplace.ListListingsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListListingsRequest + + // TODO: short flags + + // TODO: array: assets + // TODO: array: categories + cmd.Flags().BoolVar(&listReq.IsFree, "is-free", listReq.IsFree, `Filters each listing based on if it is free.`) + cmd.Flags().BoolVar(&listReq.IsPrivateExchange, "is-private-exchange", listReq.IsPrivateExchange, `Filters each listing based on if it is a private exchange.`) + cmd.Flags().BoolVar(&listReq.IsStaffPick, "is-staff-pick", listReq.IsStaffPick, `Filters each listing based on whether it is a staff pick.`) + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + // TODO: array: provider_ids + // TODO: complex arg: sort_by_spec + // TODO: array: tags + + cmd.Use = "list" + cmd.Short = `List listings.` + cmd.Long = `List listings. + + List all published listings in the Databricks Marketplace that the consumer + has access to.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ConsumerListings.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// start search 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 searchOverrides []func( + *cobra.Command, + *marketplace.SearchListingsRequest, +) + +func newSearch() *cobra.Command { + cmd := &cobra.Command{} + + var searchReq marketplace.SearchListingsRequest + + // TODO: short flags + + // TODO: array: assets + // TODO: array: categories + cmd.Flags().BoolVar(&searchReq.IsFree, "is-free", searchReq.IsFree, ``) + cmd.Flags().BoolVar(&searchReq.IsPrivateExchange, "is-private-exchange", searchReq.IsPrivateExchange, ``) + cmd.Flags().IntVar(&searchReq.PageSize, "page-size", searchReq.PageSize, ``) + cmd.Flags().StringVar(&searchReq.PageToken, "page-token", searchReq.PageToken, ``) + // TODO: array: provider_ids + cmd.Flags().Var(&searchReq.SortBy, "sort-by", `. Supported values: [SORT_BY_DATE, SORT_BY_RELEVANCE, SORT_BY_TITLE, SORT_BY_UNSPECIFIED]`) + + cmd.Use = "search QUERY" + cmd.Short = `Search listings.` + cmd.Long = `Search listings. + + Search published listings in the Databricks Marketplace that the consumer has + access to. This query supports a variety of different search parameters and + performs fuzzy matching. + + Arguments: + QUERY: Fuzzy matches query` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 QUERY argument specified. Loading names for Consumer Listings drop-down." + names, err := w.ConsumerListings.ListingSummaryNameToIdMap(ctx, marketplace.ListListingsRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Consumer Listings drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "Fuzzy matches query") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have fuzzy matches query") + } + searchReq.Query = args[0] + + response := w.ConsumerListings.Search(ctx, searchReq) + return cmdio.RenderIterator(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 searchOverrides { + fn(cmd, &searchReq) + } + + return cmd +} + +// end service ConsumerListings diff --git a/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go b/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go new file mode 100755 index 000000000..40ae4c848 --- /dev/null +++ b/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go @@ -0,0 +1,237 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package consumer_personalization_requests + +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/marketplace" + "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: "consumer-personalization-requests", + Short: `Personalization Requests allow customers to interact with the individualized Marketplace listing flow.`, + Long: `Personalization Requests allow customers to interact with the individualized + Marketplace listing flow.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + + // 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, + *marketplace.CreatePersonalizationRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreatePersonalizationRequest + 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, ``) + cmd.Flags().StringVar(&createReq.Company, "company", createReq.Company, ``) + cmd.Flags().StringVar(&createReq.FirstName, "first-name", createReq.FirstName, ``) + cmd.Flags().BoolVar(&createReq.IsFromLighthouse, "is-from-lighthouse", createReq.IsFromLighthouse, ``) + cmd.Flags().StringVar(&createReq.LastName, "last-name", createReq.LastName, ``) + cmd.Flags().Var(&createReq.RecipientType, "recipient-type", `. Supported values: [DELTA_SHARING_RECIPIENT_TYPE_DATABRICKS, DELTA_SHARING_RECIPIENT_TYPE_OPEN]`) + + cmd.Use = "create LISTING_ID" + cmd.Short = `Create a personalization request.` + cmd.Long = `Create a personalization request. + + Create a personalization request for a listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = createJson.Unmarshal(&createReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + createReq.ListingId = args[0] + + response, err := w.ConsumerPersonalizationRequests.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 +} + +// 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, + *marketplace.GetPersonalizationRequestRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetPersonalizationRequestRequest + + // TODO: short flags + + cmd.Use = "get LISTING_ID" + cmd.Short = `Get the personalization request for a listing.` + cmd.Long = `Get the personalization request for a listing. + + Get the personalization request for a listing. Each consumer can make at + *most* one personalization request for a listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + getReq.ListingId = args[0] + + response, err := w.ConsumerPersonalizationRequests.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 +} + +// 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, + *marketplace.ListAllPersonalizationRequestsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListAllPersonalizationRequestsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List all personalization requests.` + cmd.Long = `List all personalization requests. + + List personalization requests for a consumer across all listings.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ConsumerPersonalizationRequests.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// end service ConsumerPersonalizationRequests diff --git a/cmd/workspace/consumer-providers/consumer-providers.go b/cmd/workspace/consumer-providers/consumer-providers.go new file mode 100755 index 000000000..5a0849dce --- /dev/null +++ b/cmd/workspace/consumer-providers/consumer-providers.go @@ -0,0 +1,173 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package consumer_providers + +import ( + "fmt" + + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/databricks-sdk-go/service/marketplace" + "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: "consumer-providers", + Short: `Providers are the entities that publish listings to the Marketplace.`, + Long: `Providers are the entities that publish listings to the Marketplace.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + + // 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, + *marketplace.GetProviderRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetProviderRequest + + // TODO: short flags + + cmd.Use = "get ID" + cmd.Short = `Get a provider.` + cmd.Long = `Get a provider. + + Get a provider in the Databricks Marketplace with at least one visible + listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Consumer Providers drop-down." + names, err := w.ConsumerProviders.ProviderInfoNameToIdMap(ctx, marketplace.ListProvidersRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Consumer Providers drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + getReq.Id = args[0] + + response, err := w.ConsumerProviders.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 +} + +// 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, + *marketplace.ListProvidersRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListProvidersRequest + + // TODO: short flags + + cmd.Flags().BoolVar(&listReq.IsFeatured, "is-featured", listReq.IsFeatured, ``) + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List providers.` + cmd.Long = `List providers. + + List all providers in the Databricks Marketplace with at least one visible + listing.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ConsumerProviders.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// end service ConsumerProviders diff --git a/cmd/workspace/lakehouse-monitors/lakehouse-monitors.go b/cmd/workspace/lakehouse-monitors/lakehouse-monitors.go index 7e1fe20be..465ed6f92 100755 --- a/cmd/workspace/lakehouse-monitors/lakehouse-monitors.go +++ b/cmd/workspace/lakehouse-monitors/lakehouse-monitors.go @@ -68,7 +68,7 @@ func newCancelRefresh() *cobra.Command { // TODO: short flags - cmd.Use = "cancel-refresh FULL_NAME REFRESH_ID" + cmd.Use = "cancel-refresh TABLE_NAME REFRESH_ID" cmd.Short = `Cancel refresh.` cmd.Long = `Cancel refresh. @@ -84,7 +84,7 @@ func newCancelRefresh() *cobra.Command { created. Arguments: - FULL_NAME: Full name of the table. + TABLE_NAME: Full name of the table. REFRESH_ID: ID of the refresh.` // This command is being previewed; hide from help output. @@ -102,7 +102,7 @@ func newCancelRefresh() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - cancelRefreshReq.FullName = args[0] + cancelRefreshReq.TableName = args[0] cancelRefreshReq.RefreshId = args[1] err = w.LakehouseMonitors.CancelRefresh(ctx, cancelRefreshReq) @@ -154,7 +154,7 @@ func newCreate() *cobra.Command { // TODO: complex arg: time_series cmd.Flags().StringVar(&createReq.WarehouseId, "warehouse-id", createReq.WarehouseId, `Optional argument to specify the warehouse for dashboard creation.`) - cmd.Use = "create FULL_NAME ASSETS_DIR OUTPUT_SCHEMA_NAME" + cmd.Use = "create TABLE_NAME ASSETS_DIR OUTPUT_SCHEMA_NAME" cmd.Short = `Create a table monitor.` cmd.Long = `Create a table monitor. @@ -171,7 +171,7 @@ func newCreate() *cobra.Command { where this call was made. Arguments: - FULL_NAME: Full name of the table. + TABLE_NAME: Full name of the table. ASSETS_DIR: The directory to store monitoring assets (e.g. dashboard, metric tables). OUTPUT_SCHEMA_NAME: Schema where output metric tables are created.` @@ -181,7 +181,7 @@ func newCreate() *cobra.Command { if cmd.Flags().Changed("json") { err := root.ExactArgs(1)(cmd, args) if err != nil { - return fmt.Errorf("when --json flag is specified, provide only FULL_NAME as positional arguments. Provide 'assets_dir', 'output_schema_name' in your JSON input") + return fmt.Errorf("when --json flag is specified, provide only TABLE_NAME as positional arguments. Provide 'assets_dir', 'output_schema_name' in your JSON input") } return nil } @@ -200,7 +200,7 @@ func newCreate() *cobra.Command { return err } } - createReq.FullName = args[0] + createReq.TableName = args[0] if !cmd.Flags().Changed("json") { createReq.AssetsDir = args[1] } @@ -243,7 +243,7 @@ func newDelete() *cobra.Command { // TODO: short flags - cmd.Use = "delete FULL_NAME" + cmd.Use = "delete TABLE_NAME" cmd.Short = `Delete a table monitor.` cmd.Long = `Delete a table monitor. @@ -262,7 +262,7 @@ func newDelete() *cobra.Command { call; those assets must be manually cleaned up (if desired). Arguments: - FULL_NAME: Full name of the table.` + TABLE_NAME: Full name of the table.` cmd.Annotations = make(map[string]string) @@ -276,7 +276,7 @@ func newDelete() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - deleteReq.FullName = args[0] + deleteReq.TableName = args[0] err = w.LakehouseMonitors.Delete(ctx, deleteReq) if err != nil { @@ -313,7 +313,7 @@ func newGet() *cobra.Command { // TODO: short flags - cmd.Use = "get FULL_NAME" + cmd.Use = "get TABLE_NAME" cmd.Short = `Get a table monitor.` cmd.Long = `Get a table monitor. @@ -331,7 +331,7 @@ func newGet() *cobra.Command { was created. Arguments: - FULL_NAME: Full name of the table.` + TABLE_NAME: Full name of the table.` cmd.Annotations = make(map[string]string) @@ -345,7 +345,7 @@ func newGet() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - getReq.FullName = args[0] + getReq.TableName = args[0] response, err := w.LakehouseMonitors.Get(ctx, getReq) if err != nil { @@ -382,7 +382,7 @@ func newGetRefresh() *cobra.Command { // TODO: short flags - cmd.Use = "get-refresh FULL_NAME REFRESH_ID" + cmd.Use = "get-refresh TABLE_NAME REFRESH_ID" cmd.Short = `Get refresh.` cmd.Long = `Get refresh. @@ -398,7 +398,7 @@ func newGetRefresh() *cobra.Command { created. Arguments: - FULL_NAME: Full name of the table. + TABLE_NAME: Full name of the table. REFRESH_ID: ID of the refresh.` cmd.Annotations = make(map[string]string) @@ -413,7 +413,7 @@ func newGetRefresh() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - getRefreshReq.FullName = args[0] + getRefreshReq.TableName = args[0] getRefreshReq.RefreshId = args[1] response, err := w.LakehouseMonitors.GetRefresh(ctx, getRefreshReq) @@ -451,7 +451,7 @@ func newListRefreshes() *cobra.Command { // TODO: short flags - cmd.Use = "list-refreshes FULL_NAME" + cmd.Use = "list-refreshes TABLE_NAME" cmd.Short = `List refreshes.` cmd.Long = `List refreshes. @@ -468,7 +468,7 @@ func newListRefreshes() *cobra.Command { created. Arguments: - FULL_NAME: Full name of the table.` + TABLE_NAME: Full name of the table.` cmd.Annotations = make(map[string]string) @@ -482,7 +482,7 @@ func newListRefreshes() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - listRefreshesReq.FullName = args[0] + listRefreshesReq.TableName = args[0] response, err := w.LakehouseMonitors.ListRefreshes(ctx, listRefreshesReq) if err != nil { @@ -519,7 +519,7 @@ func newRunRefresh() *cobra.Command { // TODO: short flags - cmd.Use = "run-refresh FULL_NAME" + cmd.Use = "run-refresh TABLE_NAME" cmd.Short = `Queue a metric refresh for a monitor.` cmd.Long = `Queue a metric refresh for a monitor. @@ -536,7 +536,7 @@ func newRunRefresh() *cobra.Command { created. Arguments: - FULL_NAME: Full name of the table.` + TABLE_NAME: Full name of the table.` cmd.Annotations = make(map[string]string) @@ -550,7 +550,7 @@ func newRunRefresh() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - runRefreshReq.FullName = args[0] + runRefreshReq.TableName = args[0] response, err := w.LakehouseMonitors.RunRefresh(ctx, runRefreshReq) if err != nil { @@ -599,7 +599,7 @@ func newUpdate() *cobra.Command { // TODO: complex arg: snapshot // TODO: complex arg: time_series - cmd.Use = "update FULL_NAME OUTPUT_SCHEMA_NAME" + cmd.Use = "update TABLE_NAME OUTPUT_SCHEMA_NAME" cmd.Short = `Update a table monitor.` cmd.Long = `Update a table monitor. @@ -618,7 +618,7 @@ func newUpdate() *cobra.Command { updated. Arguments: - FULL_NAME: Full name of the table. + TABLE_NAME: Full name of the table. OUTPUT_SCHEMA_NAME: Schema where output metric tables are created.` cmd.Annotations = make(map[string]string) @@ -627,7 +627,7 @@ func newUpdate() *cobra.Command { if cmd.Flags().Changed("json") { err := root.ExactArgs(1)(cmd, args) if err != nil { - return fmt.Errorf("when --json flag is specified, provide only FULL_NAME as positional arguments. Provide 'output_schema_name' in your JSON input") + return fmt.Errorf("when --json flag is specified, provide only TABLE_NAME as positional arguments. Provide 'output_schema_name' in your JSON input") } return nil } @@ -646,7 +646,7 @@ func newUpdate() *cobra.Command { return err } } - updateReq.FullName = args[0] + updateReq.TableName = args[0] if !cmd.Flags().Changed("json") { updateReq.OutputSchemaName = args[1] } diff --git a/cmd/workspace/lakeview/lakeview.go b/cmd/workspace/lakeview/lakeview.go index b0136de20..566853ff9 100755 --- a/cmd/workspace/lakeview/lakeview.go +++ b/cmd/workspace/lakeview/lakeview.go @@ -272,9 +272,6 @@ func newMigrate() *cobra.Command { Arguments: SOURCE_DASHBOARD_ID: UUID of the dashboard to be migrated.` - // This command is being previewed; hide from help output. - cmd.Hidden = true - cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { @@ -475,9 +472,6 @@ func newUnpublish() *cobra.Command { Arguments: DASHBOARD_ID: UUID identifying the dashboard to be published.` - // This command is being previewed; hide from help output. - cmd.Hidden = true - cmd.Annotations = make(map[string]string) cmd.Args = func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go b/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go new file mode 100755 index 000000000..43ae6da7e --- /dev/null +++ b/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go @@ -0,0 +1,305 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_exchange_filters + +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/marketplace" + "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: "provider-exchange-filters", + Short: `Marketplace exchanges filters curate which groups can access an exchange.`, + Long: `Marketplace exchanges filters curate which groups can access an exchange.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newList()) + cmd.AddCommand(newUpdate()) + + // 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, + *marketplace.CreateExchangeFilterRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreateExchangeFilterRequest + 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 = `Create a new exchange filter.` + cmd.Long = `Create a new exchange filter. + + Add an exchange filter.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderExchangeFilters.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 +} + +// 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, + *marketplace.DeleteExchangeFilterRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq marketplace.DeleteExchangeFilterRequest + + // TODO: short flags + + cmd.Use = "delete ID" + cmd.Short = `Delete an exchange filter.` + cmd.Long = `Delete an exchange filter. + + Delete an exchange filter` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Provider Exchange Filters drop-down." + names, err := w.ProviderExchangeFilters.ExchangeFilterNameToIdMap(ctx, marketplace.ListExchangeFiltersRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Exchange Filters drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + deleteReq.Id = args[0] + + err = w.ProviderExchangeFilters.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 +} + +// 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, + *marketplace.ListExchangeFiltersRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListExchangeFiltersRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list EXCHANGE_ID" + cmd.Short = `List exchange filters.` + cmd.Long = `List exchange filters. + + List exchange filter` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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.ExchangeId = args[0] + + response := w.ProviderExchangeFilters.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// 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, + *marketplace.UpdateExchangeFilterRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdateExchangeFilterRequest + 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 = `Update exchange filter.` + cmd.Long = `Update exchange filter. + + Update an exchange filter.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + updateReq.Id = args[0] + + response, err := w.ProviderExchangeFilters.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 +} + +// end service ProviderExchangeFilters diff --git a/cmd/workspace/provider-exchanges/provider-exchanges.go b/cmd/workspace/provider-exchanges/provider-exchanges.go new file mode 100755 index 000000000..fe1a9a3dc --- /dev/null +++ b/cmd/workspace/provider-exchanges/provider-exchanges.go @@ -0,0 +1,619 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_exchanges + +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/marketplace" + "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: "provider-exchanges", + Short: `Marketplace exchanges allow providers to share their listings with a curated set of customers.`, + Long: `Marketplace exchanges allow providers to share their listings with a curated + set of customers.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newAddListingToExchange()) + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newDeleteListingFromExchange()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + cmd.AddCommand(newListExchangesForListing()) + cmd.AddCommand(newListListingsForExchange()) + cmd.AddCommand(newUpdate()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// start add-listing-to-exchange 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 addListingToExchangeOverrides []func( + *cobra.Command, + *marketplace.AddExchangeForListingRequest, +) + +func newAddListingToExchange() *cobra.Command { + cmd := &cobra.Command{} + + var addListingToExchangeReq marketplace.AddExchangeForListingRequest + var addListingToExchangeJson flags.JsonFlag + + // TODO: short flags + cmd.Flags().Var(&addListingToExchangeJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "add-listing-to-exchange LISTING_ID EXCHANGE_ID" + cmd.Short = `Add an exchange for listing.` + cmd.Long = `Add an exchange for listing. + + Associate an exchange with a listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'listing_id', 'exchange_id' in your JSON input") + } + return nil + } + check := root.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 = addListingToExchangeJson.Unmarshal(&addListingToExchangeReq) + if err != nil { + return err + } + } + if !cmd.Flags().Changed("json") { + addListingToExchangeReq.ListingId = args[0] + } + if !cmd.Flags().Changed("json") { + addListingToExchangeReq.ExchangeId = args[1] + } + + response, err := w.ProviderExchanges.AddListingToExchange(ctx, addListingToExchangeReq) + 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 addListingToExchangeOverrides { + fn(cmd, &addListingToExchangeReq) + } + + 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, + *marketplace.CreateExchangeRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreateExchangeRequest + 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 = `Create an exchange.` + cmd.Long = `Create an exchange. + + Create an exchange` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderExchanges.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 +} + +// 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, + *marketplace.DeleteExchangeRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq marketplace.DeleteExchangeRequest + + // TODO: short flags + + cmd.Use = "delete ID" + cmd.Short = `Delete an exchange.` + cmd.Long = `Delete an exchange. + + This removes a listing from marketplace.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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.ProviderExchanges.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 +} + +// start delete-listing-from-exchange 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 deleteListingFromExchangeOverrides []func( + *cobra.Command, + *marketplace.RemoveExchangeForListingRequest, +) + +func newDeleteListingFromExchange() *cobra.Command { + cmd := &cobra.Command{} + + var deleteListingFromExchangeReq marketplace.RemoveExchangeForListingRequest + + // TODO: short flags + + cmd.Use = "delete-listing-from-exchange ID" + cmd.Short = `Remove an exchange for listing.` + cmd.Long = `Remove an exchange for listing. + + Disassociate an exchange with a listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + deleteListingFromExchangeReq.Id = args[0] + + err = w.ProviderExchanges.DeleteListingFromExchange(ctx, deleteListingFromExchangeReq) + 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 deleteListingFromExchangeOverrides { + fn(cmd, &deleteListingFromExchangeReq) + } + + 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, + *marketplace.GetExchangeRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetExchangeRequest + + // TODO: short flags + + cmd.Use = "get ID" + cmd.Short = `Get an exchange.` + cmd.Long = `Get an exchange. + + Get an exchange.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + getReq.Id = args[0] + + response, err := w.ProviderExchanges.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 +} + +// 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, + *marketplace.ListExchangesRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListExchangesRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List exchanges.` + cmd.Long = `List exchanges. + + List exchanges visible to provider` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ProviderExchanges.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// start list-exchanges-for-listing 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 listExchangesForListingOverrides []func( + *cobra.Command, + *marketplace.ListExchangesForListingRequest, +) + +func newListExchangesForListing() *cobra.Command { + cmd := &cobra.Command{} + + var listExchangesForListingReq marketplace.ListExchangesForListingRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listExchangesForListingReq.PageSize, "page-size", listExchangesForListingReq.PageSize, ``) + cmd.Flags().StringVar(&listExchangesForListingReq.PageToken, "page-token", listExchangesForListingReq.PageToken, ``) + + cmd.Use = "list-exchanges-for-listing LISTING_ID" + cmd.Short = `List exchanges for listing.` + cmd.Long = `List exchanges for listing. + + List exchanges associated with a listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + listExchangesForListingReq.ListingId = args[0] + + response := w.ProviderExchanges.ListExchangesForListing(ctx, listExchangesForListingReq) + return cmdio.RenderIterator(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 listExchangesForListingOverrides { + fn(cmd, &listExchangesForListingReq) + } + + return cmd +} + +// start list-listings-for-exchange 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 listListingsForExchangeOverrides []func( + *cobra.Command, + *marketplace.ListListingsForExchangeRequest, +) + +func newListListingsForExchange() *cobra.Command { + cmd := &cobra.Command{} + + var listListingsForExchangeReq marketplace.ListListingsForExchangeRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listListingsForExchangeReq.PageSize, "page-size", listListingsForExchangeReq.PageSize, ``) + cmd.Flags().StringVar(&listListingsForExchangeReq.PageToken, "page-token", listListingsForExchangeReq.PageToken, ``) + + cmd.Use = "list-listings-for-exchange EXCHANGE_ID" + cmd.Short = `List listings for exchange.` + cmd.Long = `List listings for exchange. + + List listings associated with an exchange` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 EXCHANGE_ID argument specified. Loading names for Provider Exchanges drop-down." + names, err := w.ProviderExchanges.ExchangeListingExchangeNameToExchangeIdMap(ctx, marketplace.ListExchangesForListingRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Exchanges drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + listListingsForExchangeReq.ExchangeId = args[0] + + response := w.ProviderExchanges.ListListingsForExchange(ctx, listListingsForExchangeReq) + return cmdio.RenderIterator(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 listListingsForExchangeOverrides { + fn(cmd, &listListingsForExchangeReq) + } + + return cmd +} + +// 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, + *marketplace.UpdateExchangeRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdateExchangeRequest + 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 = `Update exchange.` + cmd.Long = `Update exchange. + + Update an exchange` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + updateReq.Id = args[0] + + response, err := w.ProviderExchanges.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 +} + +// end service ProviderExchanges diff --git a/cmd/workspace/provider-files/provider-files.go b/cmd/workspace/provider-files/provider-files.go new file mode 100755 index 000000000..b9357f131 --- /dev/null +++ b/cmd/workspace/provider-files/provider-files.go @@ -0,0 +1,315 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_files + +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/marketplace" + "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: "provider-files", + Short: `Marketplace offers a set of file APIs for various purposes such as preview notebooks and provider icons.`, + Long: `Marketplace offers a set of file APIs for various purposes such as preview + notebooks and provider icons.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + + // 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, + *marketplace.CreateFileRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreateFileRequest + 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.DisplayName, "display-name", createReq.DisplayName, ``) + + cmd.Use = "create" + cmd.Short = `Create a file.` + cmd.Long = `Create a file. + + Create a file. Currently, only provider icons and attached notebooks are + supported.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderFiles.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 +} + +// 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, + *marketplace.DeleteFileRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq marketplace.DeleteFileRequest + + // TODO: short flags + + cmd.Use = "delete FILE_ID" + cmd.Short = `Delete a file.` + cmd.Long = `Delete a file. + + Delete a file` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 FILE_ID argument specified. Loading names for Provider Files drop-down." + names, err := w.ProviderFiles.FileInfoDisplayNameToIdMap(ctx, marketplace.ListFilesRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Files drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + deleteReq.FileId = args[0] + + err = w.ProviderFiles.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 +} + +// 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, + *marketplace.GetFileRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetFileRequest + + // TODO: short flags + + cmd.Use = "get FILE_ID" + cmd.Short = `Get a file.` + cmd.Long = `Get a file. + + Get a file` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 FILE_ID argument specified. Loading names for Provider Files drop-down." + names, err := w.ProviderFiles.FileInfoDisplayNameToIdMap(ctx, marketplace.ListFilesRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Files drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + getReq.FileId = args[0] + + response, err := w.ProviderFiles.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 +} + +// 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, + *marketplace.ListFilesRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListFilesRequest + 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().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List files.` + cmd.Long = `List files. + + List files attached to a parent entity.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 = listJson.Unmarshal(&listReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + + response := w.ProviderFiles.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// end service ProviderFiles diff --git a/cmd/workspace/provider-listings/provider-listings.go b/cmd/workspace/provider-listings/provider-listings.go new file mode 100755 index 000000000..4f90f7b9e --- /dev/null +++ b/cmd/workspace/provider-listings/provider-listings.go @@ -0,0 +1,375 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_listings + +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/marketplace" + "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: "provider-listings", + Short: `Listings are the core entities in the Marketplace.`, + Long: `Listings are the core entities in the Marketplace. They represent the products + that are available for consumption.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + cmd.AddCommand(newUpdate()) + + // 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, + *marketplace.CreateListingRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreateListingRequest + 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 = `Create a listing.` + cmd.Long = `Create a listing. + + Create a new listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderListings.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 +} + +// 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, + *marketplace.DeleteListingRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq marketplace.DeleteListingRequest + + // TODO: short flags + + cmd.Use = "delete ID" + cmd.Short = `Delete a listing.` + cmd.Long = `Delete a listing. + + Delete a listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Provider Listings drop-down." + names, err := w.ProviderListings.ListingSummaryNameToIdMap(ctx, marketplace.GetListingsRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Listings drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + deleteReq.Id = args[0] + + err = w.ProviderListings.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 +} + +// 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, + *marketplace.GetListingRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetListingRequest + + // TODO: short flags + + cmd.Use = "get ID" + cmd.Short = `Get a listing.` + cmd.Long = `Get a listing. + + Get a listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Provider Listings drop-down." + names, err := w.ProviderListings.ListingSummaryNameToIdMap(ctx, marketplace.GetListingsRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Listings drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + getReq.Id = args[0] + + response, err := w.ProviderListings.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 +} + +// 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, + *marketplace.GetListingsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.GetListingsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List listings.` + cmd.Long = `List listings. + + List listings owned by this provider` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ProviderListings.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// 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, + *marketplace.UpdateListingRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdateListingRequest + 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 = `Update listing.` + cmd.Long = `Update listing. + + Update a listing` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + updateReq.Id = args[0] + + response, err := w.ProviderListings.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 +} + +// end service ProviderListings diff --git a/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go b/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go new file mode 100755 index 000000000..58b3cba1d --- /dev/null +++ b/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go @@ -0,0 +1,187 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_personalization_requests + +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/marketplace" + "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: "provider-personalization-requests", + Short: `Personalization requests are an alternate to instantly available listings.`, + Long: `Personalization requests are an alternate to instantly available listings. + Control the lifecycle of personalized solutions.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newList()) + cmd.AddCommand(newUpdate()) + + // Apply optional overrides to this command. + for _, fn := range cmdOverrides { + fn(cmd) + } + + return cmd +} + +// 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, + *marketplace.ListAllPersonalizationRequestsRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListAllPersonalizationRequestsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `All personalization requests across all listings.` + cmd.Long = `All personalization requests across all listings. + + List personalization requests to this provider. This will return all + personalization requests, regardless of which listing they are for.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ProviderPersonalizationRequests.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// 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, + *marketplace.UpdatePersonalizationRequestRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdatePersonalizationRequestRequest + 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.Flags().StringVar(&updateReq.Reason, "reason", updateReq.Reason, ``) + // TODO: complex arg: share + + cmd.Use = "update LISTING_ID REQUEST_ID STATUS" + cmd.Short = `Update personalization request status.` + cmd.Long = `Update personalization request status. + + Update personalization request. This method only permits updating the status + of the request.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(2)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only LISTING_ID, REQUEST_ID as positional arguments. Provide 'status' in your JSON input") + } + return nil + } + check := root.ExactArgs(3) + 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 + } + } + updateReq.ListingId = args[0] + updateReq.RequestId = args[1] + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[2], &updateReq.Status) + if err != nil { + return fmt.Errorf("invalid STATUS: %s", args[2]) + } + } + + response, err := w.ProviderPersonalizationRequests.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 +} + +// end service ProviderPersonalizationRequests diff --git a/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go b/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go new file mode 100755 index 000000000..70ef0f320 --- /dev/null +++ b/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go @@ -0,0 +1,252 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_provider_analytics_dashboards + +import ( + "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/marketplace" + "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: "provider-provider-analytics-dashboards", + Short: `Manage templated analytics solution for providers.`, + Long: `Manage templated analytics solution for providers.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newGetLatestVersion()) + cmd.AddCommand(newUpdate()) + + // 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, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + cmd.Use = "create" + cmd.Short = `Create provider analytics dashboard.` + cmd.Long = `Create provider analytics dashboard. + + Create provider analytics dashboard. Returns Marketplace specific id. Not to + be confused with the Lakeview dashboard id.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderProviderAnalyticsDashboards.Create(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 createOverrides { + 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, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + cmd.Use = "get" + cmd.Short = `Get provider analytics dashboard.` + cmd.Long = `Get provider analytics dashboard. + + Get provider analytics dashboard.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderProviderAnalyticsDashboards.Get(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 getOverrides { + fn(cmd) + } + + return cmd +} + +// start get-latest-version 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 getLatestVersionOverrides []func( + *cobra.Command, +) + +func newGetLatestVersion() *cobra.Command { + cmd := &cobra.Command{} + + cmd.Use = "get-latest-version" + cmd.Short = `Get latest version of provider analytics dashboard.` + cmd.Long = `Get latest version of provider analytics dashboard. + + Get latest version of provider analytics dashboard.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderProviderAnalyticsDashboards.GetLatestVersion(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 getLatestVersionOverrides { + fn(cmd) + } + + return cmd +} + +// 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, + *marketplace.UpdateProviderAnalyticsDashboardRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdateProviderAnalyticsDashboardRequest + 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.Flags().Int64Var(&updateReq.Version, "version", updateReq.Version, `this is the version of the dashboard template we want to update our user to current expectation is that it should be equal to latest version of the dashboard template.`) + + cmd.Use = "update ID" + cmd.Short = `Update provider analytics dashboard.` + cmd.Long = `Update provider analytics dashboard. + + Update provider analytics dashboard. + + Arguments: + ID: id is immutable property and can't be updated.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } + updateReq.Id = args[0] + + response, err := w.ProviderProviderAnalyticsDashboards.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 +} + +// end service ProviderProviderAnalyticsDashboards diff --git a/cmd/workspace/provider-providers/provider-providers.go b/cmd/workspace/provider-providers/provider-providers.go new file mode 100755 index 000000000..52f4c45ae --- /dev/null +++ b/cmd/workspace/provider-providers/provider-providers.go @@ -0,0 +1,374 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package provider_providers + +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/marketplace" + "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: "provider-providers", + Short: `Providers are entities that manage assets in Marketplace.`, + Long: `Providers are entities that manage assets in Marketplace.`, + GroupID: "marketplace", + Annotations: map[string]string{ + "package": "marketplace", + }, + + // This service is being previewed; hide from help output. + Hidden: true, + } + + // Add methods + cmd.AddCommand(newCreate()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newList()) + cmd.AddCommand(newUpdate()) + + // 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, + *marketplace.CreateProviderRequest, +) + +func newCreate() *cobra.Command { + cmd := &cobra.Command{} + + var createReq marketplace.CreateProviderRequest + 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 = `Create a provider.` + cmd.Long = `Create a provider. + + Create a provider` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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.ProviderProviders.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 +} + +// 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, + *marketplace.DeleteProviderRequest, +) + +func newDelete() *cobra.Command { + cmd := &cobra.Command{} + + var deleteReq marketplace.DeleteProviderRequest + + // TODO: short flags + + cmd.Use = "delete ID" + cmd.Short = `Delete provider.` + cmd.Long = `Delete provider. + + Delete provider` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Provider Providers drop-down." + names, err := w.ProviderProviders.ProviderInfoNameToIdMap(ctx, marketplace.ListProvidersRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Providers drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + deleteReq.Id = args[0] + + err = w.ProviderProviders.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 +} + +// 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, + *marketplace.GetProviderRequest, +) + +func newGet() *cobra.Command { + cmd := &cobra.Command{} + + var getReq marketplace.GetProviderRequest + + // TODO: short flags + + cmd.Use = "get ID" + cmd.Short = `Get provider.` + cmd.Long = `Get provider. + + Get provider profile` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + 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 ID argument specified. Loading names for Provider Providers drop-down." + names, err := w.ProviderProviders.ProviderInfoNameToIdMap(ctx, marketplace.ListProvidersRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Provider Providers drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + getReq.Id = args[0] + + response, err := w.ProviderProviders.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 +} + +// 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, + *marketplace.ListProvidersRequest, +) + +func newList() *cobra.Command { + cmd := &cobra.Command{} + + var listReq marketplace.ListProvidersRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, ``) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, ``) + + cmd.Use = "list" + cmd.Short = `List providers.` + cmd.Long = `List providers. + + List provider profiles for account.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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) + + response := w.ProviderProviders.List(ctx, listReq) + return cmdio.RenderIterator(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 +} + +// 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, + *marketplace.UpdateProviderRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq marketplace.UpdateProviderRequest + 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 = `Update provider.` + cmd.Long = `Update provider. + + Update provider profile` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.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 = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + updateReq.Id = args[0] + + response, err := w.ProviderProviders.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 +} + +// end service ProviderProviders From 8254e56b8ca214f5c414b077e25264511791f873 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 15 Apr 2024 16:50:07 +0200 Subject: [PATCH 3/3] fix test --- cmd/workspace/groups.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/workspace/groups.go b/cmd/workspace/groups.go index 8f3768137..d8a4dec4f 100644 --- a/cmd/workspace/groups.go +++ b/cmd/workspace/groups.go @@ -64,5 +64,9 @@ func Groups() []cobra.Group { ID: "dashboards", Title: "Dashboards", }, + { + ID: "marketplace", + Title: "Marketplace", + }, } }