2023-07-18 17:13:48 +00:00
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package clean_rooms
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/sharing"
"github.com/spf13/cobra"
)
2023-07-25 18:19:07 +00:00
// 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 : "clean-rooms" ,
Short : ` A clean room is a secure, privacy-protecting environment where two or more parties can share sensitive enterprise data, including customer data, for measurements, insights, activation and other use cases. ` ,
Long : ` A clean room is a secure , privacy - protecting environment where two or more
2023-07-18 17:13:48 +00:00
parties can share sensitive enterprise data , including customer data , for
measurements , insights , activation and other use cases .
To create clean rooms , you must be a metastore admin or a user with the
* * CREATE_CLEAN_ROOM * * privilege . ` ,
2023-07-25 18:19:07 +00:00
GroupID : "sharing" ,
Annotations : map [ string ] string {
"package" : "sharing" ,
} ,
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
// This service is being previewed; hide from help output.
Hidden : true ,
}
// Apply optional overrides to this command.
for _ , fn := range cmdOverrides {
fn ( cmd )
}
return cmd
2023-07-18 17:13:48 +00:00
}
// start create command
2023-07-25 18:19:07 +00:00
// 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 ,
* sharing . CreateCleanRoom ,
)
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
func newCreate ( ) * cobra . Command {
cmd := & cobra . Command { }
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
var createReq sharing . CreateCleanRoom
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 , ` User-provided free-form text description. ` )
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Use = "create"
cmd . Short = ` Create a clean room. `
cmd . Long = ` Create a clean room .
2023-07-18 17:13:48 +00:00
Creates a new clean room with specified colaborators . The caller must be a
2023-07-25 18:19:07 +00:00
metastore admin or have the * * CREATE_CLEAN_ROOM * * privilege on the metastore . `
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Annotations = make ( map [ string ] string )
cmd . PreRunE = root . MustWorkspaceClient
cmd . RunE = func ( cmd * cobra . Command , args [ ] string ) ( err error ) {
2023-07-18 17:13:48 +00:00
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 . CleanRooms . Create ( ctx , createReq )
if err != nil {
return err
}
return cmdio . Render ( ctx , response )
2023-07-25 18:19:07 +00:00
}
2023-07-18 17:13:48 +00:00
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
2023-07-25 18:19:07 +00:00
cmd . ValidArgsFunction = cobra . NoFileCompletions
// Apply optional overrides to this command.
for _ , fn := range createOverrides {
fn ( cmd , & createReq )
}
return cmd
}
func init ( ) {
cmdOverrides = append ( cmdOverrides , func ( cmd * cobra . Command ) {
cmd . AddCommand ( newCreate ( ) )
} )
2023-07-18 17:13:48 +00:00
}
// start delete command
2023-07-25 18:19:07 +00:00
// 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 ,
* sharing . DeleteCleanRoomRequest ,
)
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
func newDelete ( ) * cobra . Command {
cmd := & cobra . Command { }
var deleteReq sharing . DeleteCleanRoomRequest
// TODO: short flags
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Use = "delete NAME_ARG"
cmd . Short = ` Delete a clean room. `
cmd . Long = ` Delete a clean room .
2023-07-18 17:13:48 +00:00
Deletes a data object clean room from the metastore . The caller must be an
2023-11-30 16:22:23 +00:00
owner of the clean room .
Arguments :
NAME_ARG : The name of the clean room . `
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Annotations = make ( map [ string ] string )
cmd . Args = func ( cmd * cobra . Command , args [ ] string ) error {
2023-07-18 17:13:48 +00:00
check := cobra . ExactArgs ( 1 )
return check ( cmd , args )
2023-07-25 18:19:07 +00:00
}
cmd . PreRunE = root . MustWorkspaceClient
cmd . RunE = func ( cmd * cobra . Command , args [ ] string ) ( err error ) {
2023-07-18 17:13:48 +00:00
ctx := cmd . Context ( )
w := root . WorkspaceClient ( ctx )
deleteReq . NameArg = args [ 0 ]
err = w . CleanRooms . Delete ( ctx , deleteReq )
if err != nil {
return err
}
return nil
2023-07-25 18:19:07 +00:00
}
2023-07-18 17:13:48 +00:00
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
2023-07-25 18:19:07 +00:00
cmd . ValidArgsFunction = cobra . NoFileCompletions
// Apply optional overrides to this command.
for _ , fn := range deleteOverrides {
fn ( cmd , & deleteReq )
}
return cmd
}
func init ( ) {
cmdOverrides = append ( cmdOverrides , func ( cmd * cobra . Command ) {
cmd . AddCommand ( newDelete ( ) )
} )
2023-07-18 17:13:48 +00:00
}
// start get command
2023-07-25 18:19:07 +00:00
// 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 ,
* sharing . GetCleanRoomRequest ,
)
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
func newGet ( ) * cobra . Command {
cmd := & cobra . Command { }
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
var getReq sharing . GetCleanRoomRequest
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
// TODO: short flags
cmd . Flags ( ) . BoolVar ( & getReq . IncludeRemoteDetails , "include-remote-details" , getReq . IncludeRemoteDetails , ` Whether to include remote details (central) on the clean room. ` )
cmd . Use = "get NAME_ARG"
cmd . Short = ` Get a clean room. `
cmd . Long = ` Get a clean room .
2023-07-18 17:13:48 +00:00
Gets a data object clean room from the metastore . The caller must be a
2023-11-30 16:22:23 +00:00
metastore admin or the owner of the clean room .
Arguments :
NAME_ARG : The name of the clean room . `
2023-07-25 18:19:07 +00:00
cmd . Annotations = make ( map [ string ] string )
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Args = func ( cmd * cobra . Command , args [ ] string ) error {
2023-07-18 17:13:48 +00:00
check := cobra . ExactArgs ( 1 )
return check ( cmd , args )
2023-07-25 18:19:07 +00:00
}
cmd . PreRunE = root . MustWorkspaceClient
cmd . RunE = func ( cmd * cobra . Command , args [ ] string ) ( err error ) {
2023-07-18 17:13:48 +00:00
ctx := cmd . Context ( )
w := root . WorkspaceClient ( ctx )
getReq . NameArg = args [ 0 ]
response , err := w . CleanRooms . Get ( ctx , getReq )
if err != nil {
return err
}
return cmdio . Render ( ctx , response )
2023-07-25 18:19:07 +00:00
}
2023-07-18 17:13:48 +00:00
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
2023-07-25 18:19:07 +00:00
cmd . ValidArgsFunction = cobra . NoFileCompletions
// Apply optional overrides to this command.
for _ , fn := range getOverrides {
fn ( cmd , & getReq )
}
return cmd
}
func init ( ) {
cmdOverrides = append ( cmdOverrides , func ( cmd * cobra . Command ) {
cmd . AddCommand ( newGet ( ) )
} )
2023-07-18 17:13:48 +00:00
}
// start list command
2023-07-25 18:19:07 +00:00
// 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 ,
2023-10-03 11:46:16 +00:00
* sharing . ListCleanRoomsRequest ,
2023-07-25 18:19:07 +00:00
)
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
func newList ( ) * cobra . Command {
cmd := & cobra . Command { }
2023-07-18 17:13:48 +00:00
2023-10-03 11:46:16 +00:00
var listReq sharing . ListCleanRoomsRequest
// TODO: short flags
cmd . Flags ( ) . IntVar ( & listReq . MaxResults , "max-results" , listReq . MaxResults , ` Maximum number of clean rooms to return. ` )
2024-01-11 08:16:25 +00:00
cmd . Flags ( ) . StringVar ( & listReq . PageToken , "page-token" , listReq . PageToken , ` Opaque pagination token to go to next page based on previous query. ` )
2023-10-03 11:46:16 +00:00
2023-07-25 18:19:07 +00:00
cmd . Use = "list"
cmd . Short = ` List clean rooms. `
cmd . Long = ` List clean rooms .
2023-07-18 17:13:48 +00:00
Gets an array of data object clean rooms from the metastore . The caller must
be a metastore admin or the owner of the clean room . There is no guarantee of
2023-07-25 18:19:07 +00:00
a specific ordering of the elements in the array . `
cmd . Annotations = make ( map [ string ] string )
2023-07-18 17:13:48 +00:00
2023-10-03 11:46:16 +00:00
cmd . Args = func ( cmd * cobra . Command , args [ ] string ) error {
check := cobra . ExactArgs ( 0 )
return check ( cmd , args )
}
2023-07-25 18:19:07 +00:00
cmd . PreRunE = root . MustWorkspaceClient
cmd . RunE = func ( cmd * cobra . Command , args [ ] string ) ( err error ) {
2023-07-18 17:13:48 +00:00
ctx := cmd . Context ( )
w := root . WorkspaceClient ( ctx )
2023-10-03 11:46:16 +00:00
response , err := w . CleanRooms . ListAll ( ctx , listReq )
2023-07-18 17:13:48 +00:00
if err != nil {
return err
}
return cmdio . Render ( ctx , response )
2023-07-25 18:19:07 +00:00
}
2023-07-18 17:13:48 +00:00
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
2023-07-25 18:19:07 +00:00
cmd . ValidArgsFunction = cobra . NoFileCompletions
// Apply optional overrides to this command.
for _ , fn := range listOverrides {
2023-10-03 11:46:16 +00:00
fn ( cmd , & listReq )
2023-07-25 18:19:07 +00:00
}
return cmd
}
func init ( ) {
cmdOverrides = append ( cmdOverrides , func ( cmd * cobra . Command ) {
cmd . AddCommand ( newList ( ) )
} )
2023-07-18 17:13:48 +00:00
}
// start update command
2023-07-25 18:19:07 +00:00
// 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 ,
* sharing . UpdateCleanRoom ,
)
func newUpdate ( ) * cobra . Command {
cmd := & cobra . Command { }
var updateReq sharing . UpdateCleanRoom
var updateJson flags . JsonFlag
2023-07-18 17:13:48 +00:00
// TODO: short flags
2023-07-25 18:19:07 +00:00
cmd . Flags ( ) . Var ( & updateJson , "json" , ` either inline JSON string or @path/to/file.json with request body ` )
2023-07-18 17:13:48 +00:00
// TODO: array: catalog_updates
2023-07-25 18:19:07 +00:00
cmd . Flags ( ) . StringVar ( & updateReq . Comment , "comment" , updateReq . Comment , ` User-provided free-form text description. ` )
cmd . Flags ( ) . StringVar ( & updateReq . Owner , "owner" , updateReq . Owner , ` Username of current owner of clean room. ` )
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Use = "update NAME_ARG"
cmd . Short = ` Update a clean room. `
cmd . Long = ` Update a clean room .
2023-07-18 17:13:48 +00:00
Updates the clean room with the changes and data objects in the request . The
caller must be the owner of the clean room or a metastore admin .
When the caller is a metastore admin , only the __owner__ field can be updated .
In the case that the clean room name is changed * * updateCleanRoom * * requires
that the caller is both the clean room owner and a metastore admin .
For each table that is added through this method , the clean room owner must
also have * * SELECT * * privilege on the table . The privilege must be maintained
indefinitely for recipients to be able to access the table . Typically , you
should use a group as the clean room owner .
2023-11-30 16:22:23 +00:00
Table removals through * * update * * do not require additional privileges .
Arguments :
NAME_ARG : The name of the clean room . `
2023-07-18 17:13:48 +00:00
2023-07-25 18:19:07 +00:00
cmd . Annotations = make ( map [ string ] string )
cmd . Args = func ( cmd * cobra . Command , args [ ] string ) error {
2023-07-18 17:13:48 +00:00
check := cobra . ExactArgs ( 1 )
return check ( cmd , args )
2023-07-25 18:19:07 +00:00
}
cmd . PreRunE = root . MustWorkspaceClient
cmd . RunE = func ( cmd * cobra . Command , args [ ] string ) ( err error ) {
2023-07-18 17:13:48 +00:00
ctx := cmd . Context ( )
w := root . WorkspaceClient ( ctx )
if cmd . Flags ( ) . Changed ( "json" ) {
err = updateJson . Unmarshal ( & updateReq )
if err != nil {
return err
}
}
updateReq . NameArg = args [ 0 ]
response , err := w . CleanRooms . Update ( ctx , updateReq )
if err != nil {
return err
}
return cmdio . Render ( ctx , response )
2023-07-25 18:19:07 +00:00
}
2023-07-18 17:13:48 +00:00
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
2023-07-25 18:19:07 +00:00
cmd . ValidArgsFunction = cobra . NoFileCompletions
// Apply optional overrides to this command.
for _ , fn := range updateOverrides {
fn ( cmd , & updateReq )
}
return cmd
}
func init ( ) {
cmdOverrides = append ( cmdOverrides , func ( cmd * cobra . Command ) {
cmd . AddCommand ( newUpdate ( ) )
} )
2023-07-18 17:13:48 +00:00
}
// end service CleanRooms