databricks-cli/cmd/workspace/consumer-personalization-re.../consumer-personalization-re...

232 lines
6.6 KiB
Go
Executable File

// 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",
},
}
// 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.`
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") {
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
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.`
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.`
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