From ae9cd2257f24251e2b1cce4fc659cefed68df955 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Sat, 10 Dec 2022 18:06:17 +0100 Subject: [PATCH 1/4] Fix redash mapping --- service/mlflow/model.go | 5 +++-- service/sql/model.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/service/mlflow/model.go b/service/mlflow/model.go index 42cda2712..afc46dc51 100755 --- a/service/mlflow/model.go +++ b/service/mlflow/model.go @@ -836,8 +836,9 @@ type ModelVersionDatabricks struct { // Unique identifier for the MLflow tracking run associated with the source // model artifacts. RunId string `json:"run_id,omitempty"` - // URL of the run associated with the model artifacts, potentially in - // another workspace. + // URL of the run associated with the model artifacts. This field is set at + // model version creation time only for model versions whose source run is + // from a tracking server that is different from the registry server. RunLink string `json:"run_link,omitempty"` // URI that indicates the location of the source model artifacts. This is // used when creating the model version. diff --git a/service/sql/model.go b/service/sql/model.go index a2e25d0db..9e87df9ac 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -1436,7 +1436,7 @@ type Parameter struct { // Parameters can have several different types. Type ParameterType `json:"type,omitempty"` // The default value for this parameter. - Value string `json:"value,omitempty"` + Value any `json:"value,omitempty"` } // Parameters can have several different types. From 5bac7cf26c11e834cd55eb5272e0363855e7802f Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Sat, 10 Dec 2022 18:27:33 +0100 Subject: [PATCH 2/4] fix warehouses enums --- service/sql/api.go | 28 +-- service/sql/model.go | 570 ++++++++++--------------------------------- 2 files changed, 148 insertions(+), 450 deletions(-) diff --git a/service/sql/api.go b/service/sql/api.go index ee263d5ed..f7681e45e 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -903,11 +903,11 @@ func (a *WarehousesAPI) CreateAndWait(ctx context.Context, createWarehouseReques statusMessage = getWarehouseResponse.Health.Summary } switch status { - case GetWarehouseResponseStateRunning: // target state + case StateRunning: // target state return getWarehouseResponse, nil - case GetWarehouseResponseStateStopped, GetWarehouseResponseStateDeleted: + case StateStopped, StateDeleted: err := fmt.Errorf("failed to reach %s, got %s: %s", - GetWarehouseResponseStateRunning, status, statusMessage) + StateRunning, status, statusMessage) return nil, retries.Halt(err) default: return nil, retries.Continues(statusMessage) @@ -955,7 +955,7 @@ func (a *WarehousesAPI) DeleteAndWait(ctx context.Context, deleteWarehouseReques statusMessage = getWarehouseResponse.Health.Summary } switch status { - case GetWarehouseResponseStateDeleted: // target state + case StateDeleted: // target state return getWarehouseResponse, nil default: return nil, retries.Continues(statusMessage) @@ -1018,11 +1018,11 @@ func (a *WarehousesAPI) EditAndWait(ctx context.Context, editWarehouseRequest Ed statusMessage = getWarehouseResponse.Health.Summary } switch status { - case GetWarehouseResponseStateRunning: // target state + case StateRunning: // target state return getWarehouseResponse, nil - case GetWarehouseResponseStateStopped, GetWarehouseResponseStateDeleted: + case StateStopped, StateDeleted: err := fmt.Errorf("failed to reach %s, got %s: %s", - GetWarehouseResponseStateRunning, status, statusMessage) + StateRunning, status, statusMessage) return nil, retries.Halt(err) default: return nil, retries.Continues(statusMessage) @@ -1070,11 +1070,11 @@ func (a *WarehousesAPI) GetAndWait(ctx context.Context, getWarehouseRequest GetW statusMessage = getWarehouseResponse.Health.Summary } switch status { - case GetWarehouseResponseStateRunning: // target state + case StateRunning: // target state return getWarehouseResponse, nil - case GetWarehouseResponseStateStopped, GetWarehouseResponseStateDeleted: + case StateStopped, StateDeleted: err := fmt.Errorf("failed to reach %s, got %s: %s", - GetWarehouseResponseStateRunning, status, statusMessage) + StateRunning, status, statusMessage) return nil, retries.Halt(err) default: return nil, retries.Continues(statusMessage) @@ -1219,11 +1219,11 @@ func (a *WarehousesAPI) StartAndWait(ctx context.Context, startRequest StartRequ statusMessage = getWarehouseResponse.Health.Summary } switch status { - case GetWarehouseResponseStateRunning: // target state + case StateRunning: // target state return getWarehouseResponse, nil - case GetWarehouseResponseStateStopped, GetWarehouseResponseStateDeleted: + case StateStopped, StateDeleted: err := fmt.Errorf("failed to reach %s, got %s: %s", - GetWarehouseResponseStateRunning, status, statusMessage) + StateRunning, status, statusMessage) return nil, retries.Halt(err) default: return nil, retries.Continues(statusMessage) @@ -1271,7 +1271,7 @@ func (a *WarehousesAPI) StopAndWait(ctx context.Context, stopRequest StopRequest statusMessage = getWarehouseResponse.Health.Summary } switch status { - case GetWarehouseResponseStateStopped: // target state + case StateStopped: // target state return getWarehouseResponse, nil default: return nil, retries.Continues(statusMessage) diff --git a/service/sql/model.go b/service/sql/model.go index 9e87df9ac..2069b44f9 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -243,89 +243,15 @@ type CreateWarehouseRequest struct { // Supported values: - Must be unique within an org. - Must be less than 100 // characters. Name string `json:"name,omitempty"` - // Configurations whether the endpoint should use spot instances. - // - // Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" - // - // Defaults to COST_OPTIMIZED. - // - // Please refer to documentation for EndpointSpotInstancePolicy for more - // details. - SpotInstancePolicy CreateWarehouseRequestSpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // Configurations whether the warehouse should use spot instances. + SpotInstancePolicy SpotInstancePolicy `json:"spot_instance_policy,omitempty"` // A set of key-value pairs that will be tagged on all resources (e.g., AWS // instances and EBS volumes) associated with this SQL Endpoints. // // Supported values: - Number of tags < 45. Tags *EndpointTags `json:"tags,omitempty"` - // Warehouse type (Classic/Pro) - WarehouseType CreateWarehouseRequestWarehouseType `json:"warehouse_type,omitempty"` -} - -// Configurations whether the endpoint should use spot instances. -// -// Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" -// -// Defaults to COST_OPTIMIZED. -// -// Please refer to documentation for EndpointSpotInstancePolicy for more -// details. -type CreateWarehouseRequestSpotInstancePolicy string - -const CreateWarehouseRequestSpotInstancePolicyCostOptimized CreateWarehouseRequestSpotInstancePolicy = `COST_OPTIMIZED` - -const CreateWarehouseRequestSpotInstancePolicyPolicyUnspecified CreateWarehouseRequestSpotInstancePolicy = `POLICY_UNSPECIFIED` - -const CreateWarehouseRequestSpotInstancePolicyReliabilityOptimized CreateWarehouseRequestSpotInstancePolicy = `RELIABILITY_OPTIMIZED` - -// String representation for [fmt.Print] -func (cwrsip *CreateWarehouseRequestSpotInstancePolicy) String() string { - return string(*cwrsip) -} - -// Set raw string value and validate it against allowed values -func (cwrsip *CreateWarehouseRequestSpotInstancePolicy) Set(v string) error { - switch v { - case `COST_OPTIMIZED`, `POLICY_UNSPECIFIED`, `RELIABILITY_OPTIMIZED`: - *cwrsip = CreateWarehouseRequestSpotInstancePolicy(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED"`, v) - } -} -// Type always returns CreateWarehouseRequestSpotInstancePolicy to satisfy [pflag.Value] interface -func (cwrsip *CreateWarehouseRequestSpotInstancePolicy) Type() string { - return "CreateWarehouseRequestSpotInstancePolicy" -} - -// Warehouse type (Classic/Pro) -type CreateWarehouseRequestWarehouseType string - -const CreateWarehouseRequestWarehouseTypeClassic CreateWarehouseRequestWarehouseType = `CLASSIC` - -const CreateWarehouseRequestWarehouseTypePro CreateWarehouseRequestWarehouseType = `PRO` - -const CreateWarehouseRequestWarehouseTypeTypeUnspecified CreateWarehouseRequestWarehouseType = `TYPE_UNSPECIFIED` - -// String representation for [fmt.Print] -func (cwrwt *CreateWarehouseRequestWarehouseType) String() string { - return string(*cwrwt) -} - -// Set raw string value and validate it against allowed values -func (cwrwt *CreateWarehouseRequestWarehouseType) Set(v string) error { - switch v { - case `CLASSIC`, `PRO`, `TYPE_UNSPECIFIED`: - *cwrwt = CreateWarehouseRequestWarehouseType(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "CLASSIC", "PRO", "TYPE_UNSPECIFIED"`, v) - } -} - -// Type always returns CreateWarehouseRequestWarehouseType to satisfy [pflag.Value] interface -func (cwrwt *CreateWarehouseRequestWarehouseType) Type() string { - return "CreateWarehouseRequestWarehouseType" + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` } type CreateWarehouseResponse struct { @@ -563,89 +489,15 @@ type EditWarehouseRequest struct { // Supported values: - Must be unique within an org. - Must be less than 100 // characters. Name string `json:"name,omitempty"` - // Configurations whether the endpoint should use spot instances. - // - // Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" - // - // Defaults to COST_OPTIMIZED. - // - // Please refer to documentation for EndpointSpotInstancePolicy for more - // details. - SpotInstancePolicy EditWarehouseRequestSpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // Configurations whether the warehouse should use spot instances. + SpotInstancePolicy SpotInstancePolicy `json:"spot_instance_policy,omitempty"` // A set of key-value pairs that will be tagged on all resources (e.g., AWS // instances and EBS volumes) associated with this SQL Endpoints. // // Supported values: - Number of tags < 45. Tags *EndpointTags `json:"tags,omitempty"` - // Warehouse type (Classic/Pro) - WarehouseType EditWarehouseRequestWarehouseType `json:"warehouse_type,omitempty"` -} - -// Configurations whether the endpoint should use spot instances. -// -// Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" -// -// Defaults to COST_OPTIMIZED. -// -// Please refer to documentation for EndpointSpotInstancePolicy for more -// details. -type EditWarehouseRequestSpotInstancePolicy string - -const EditWarehouseRequestSpotInstancePolicyCostOptimized EditWarehouseRequestSpotInstancePolicy = `COST_OPTIMIZED` - -const EditWarehouseRequestSpotInstancePolicyPolicyUnspecified EditWarehouseRequestSpotInstancePolicy = `POLICY_UNSPECIFIED` - -const EditWarehouseRequestSpotInstancePolicyReliabilityOptimized EditWarehouseRequestSpotInstancePolicy = `RELIABILITY_OPTIMIZED` - -// String representation for [fmt.Print] -func (ewrsip *EditWarehouseRequestSpotInstancePolicy) String() string { - return string(*ewrsip) -} - -// Set raw string value and validate it against allowed values -func (ewrsip *EditWarehouseRequestSpotInstancePolicy) Set(v string) error { - switch v { - case `COST_OPTIMIZED`, `POLICY_UNSPECIFIED`, `RELIABILITY_OPTIMIZED`: - *ewrsip = EditWarehouseRequestSpotInstancePolicy(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED"`, v) - } -} - -// Type always returns EditWarehouseRequestSpotInstancePolicy to satisfy [pflag.Value] interface -func (ewrsip *EditWarehouseRequestSpotInstancePolicy) Type() string { - return "EditWarehouseRequestSpotInstancePolicy" -} - -// Warehouse type (Classic/Pro) -type EditWarehouseRequestWarehouseType string - -const EditWarehouseRequestWarehouseTypeClassic EditWarehouseRequestWarehouseType = `CLASSIC` - -const EditWarehouseRequestWarehouseTypePro EditWarehouseRequestWarehouseType = `PRO` - -const EditWarehouseRequestWarehouseTypeTypeUnspecified EditWarehouseRequestWarehouseType = `TYPE_UNSPECIFIED` - -// String representation for [fmt.Print] -func (ewrwt *EditWarehouseRequestWarehouseType) String() string { - return string(*ewrwt) -} - -// Set raw string value and validate it against allowed values -func (ewrwt *EditWarehouseRequestWarehouseType) Set(v string) error { - switch v { - case `CLASSIC`, `PRO`, `TYPE_UNSPECIFIED`: - *ewrwt = EditWarehouseRequestWarehouseType(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "CLASSIC", "PRO", "TYPE_UNSPECIFIED"`, v) - } -} -// Type always returns EditWarehouseRequestWarehouseType to satisfy [pflag.Value] interface -func (ewrwt *EditWarehouseRequestWarehouseType) Type() string { - return "EditWarehouseRequestWarehouseType" + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` } type EndpointConfPair struct { @@ -663,44 +515,12 @@ type EndpointHealth struct { // Deprecated. split into summary and details for security Message string `json:"message,omitempty"` // Health status of the endpoint. - Status EndpointHealthStatus `json:"status,omitempty"` + Status Status `json:"status,omitempty"` // A short summary of the health status in case of degraded/failed // endpoints. Summary string `json:"summary,omitempty"` } -// Health status of the endpoint. -type EndpointHealthStatus string - -const EndpointHealthStatusDegraded EndpointHealthStatus = `DEGRADED` - -const EndpointHealthStatusFailed EndpointHealthStatus = `FAILED` - -const EndpointHealthStatusHealthy EndpointHealthStatus = `HEALTHY` - -const EndpointHealthStatusStatusUnspecified EndpointHealthStatus = `STATUS_UNSPECIFIED` - -// String representation for [fmt.Print] -func (ehs *EndpointHealthStatus) String() string { - return string(*ehs) -} - -// Set raw string value and validate it against allowed values -func (ehs *EndpointHealthStatus) Set(v string) error { - switch v { - case `DEGRADED`, `FAILED`, `HEALTHY`, `STATUS_UNSPECIFIED`: - *ehs = EndpointHealthStatus(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "DEGRADED", "FAILED", "HEALTHY", "STATUS_UNSPECIFIED"`, v) - } -} - -// Type always returns EndpointHealthStatus to satisfy [pflag.Value] interface -func (ehs *EndpointHealthStatus) Type() string { - return "EndpointHealthStatus" -} - type EndpointInfo struct { // The amount of time in minutes that a SQL Endpoint must be idle (i.e., no // RUNNING queries) before it is automatically stopped. @@ -772,127 +592,17 @@ type EndpointInfo struct { NumClusters int `json:"num_clusters,omitempty"` // ODBC parameters for the sql endpoint OdbcParams *OdbcParams `json:"odbc_params,omitempty"` - // Configurations whether the endpoint should use spot instances. - // - // Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" - // - // Defaults to COST_OPTIMIZED. - // - // Please refer to documentation for EndpointSpotInstancePolicy for more - // details. - SpotInstancePolicy EndpointInfoSpotInstancePolicy `json:"spot_instance_policy,omitempty"` - // state of the endpoint - State EndpointInfoState `json:"state,omitempty"` + // Configurations whether the warehouse should use spot instances. + SpotInstancePolicy SpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // State of the warehouse + State State `json:"state,omitempty"` // A set of key-value pairs that will be tagged on all resources (e.g., AWS // instances and EBS volumes) associated with this SQL Endpoints. // // Supported values: - Number of tags < 45. Tags *EndpointTags `json:"tags,omitempty"` - // Warehouse type (Classic/Pro) - WarehouseType EndpointInfoWarehouseType `json:"warehouse_type,omitempty"` -} - -// Configurations whether the endpoint should use spot instances. -// -// Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" -// -// Defaults to COST_OPTIMIZED. -// -// Please refer to documentation for EndpointSpotInstancePolicy for more -// details. -type EndpointInfoSpotInstancePolicy string - -const EndpointInfoSpotInstancePolicyCostOptimized EndpointInfoSpotInstancePolicy = `COST_OPTIMIZED` - -const EndpointInfoSpotInstancePolicyPolicyUnspecified EndpointInfoSpotInstancePolicy = `POLICY_UNSPECIFIED` - -const EndpointInfoSpotInstancePolicyReliabilityOptimized EndpointInfoSpotInstancePolicy = `RELIABILITY_OPTIMIZED` -// String representation for [fmt.Print] -func (eisip *EndpointInfoSpotInstancePolicy) String() string { - return string(*eisip) -} - -// Set raw string value and validate it against allowed values -func (eisip *EndpointInfoSpotInstancePolicy) Set(v string) error { - switch v { - case `COST_OPTIMIZED`, `POLICY_UNSPECIFIED`, `RELIABILITY_OPTIMIZED`: - *eisip = EndpointInfoSpotInstancePolicy(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED"`, v) - } -} - -// Type always returns EndpointInfoSpotInstancePolicy to satisfy [pflag.Value] interface -func (eisip *EndpointInfoSpotInstancePolicy) Type() string { - return "EndpointInfoSpotInstancePolicy" -} - -// state of the endpoint -type EndpointInfoState string - -const EndpointInfoStateDeleted EndpointInfoState = `DELETED` - -const EndpointInfoStateDeleting EndpointInfoState = `DELETING` - -const EndpointInfoStateRunning EndpointInfoState = `RUNNING` - -const EndpointInfoStateStarting EndpointInfoState = `STARTING` - -const EndpointInfoStateStopped EndpointInfoState = `STOPPED` - -const EndpointInfoStateStopping EndpointInfoState = `STOPPING` - -// String representation for [fmt.Print] -func (eis *EndpointInfoState) String() string { - return string(*eis) -} - -// Set raw string value and validate it against allowed values -func (eis *EndpointInfoState) Set(v string) error { - switch v { - case `DELETED`, `DELETING`, `RUNNING`, `STARTING`, `STOPPED`, `STOPPING`: - *eis = EndpointInfoState(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "DELETED", "DELETING", "RUNNING", "STARTING", "STOPPED", "STOPPING"`, v) - } -} - -// Type always returns EndpointInfoState to satisfy [pflag.Value] interface -func (eis *EndpointInfoState) Type() string { - return "EndpointInfoState" -} - -// Warehouse type (Classic/Pro) -type EndpointInfoWarehouseType string - -const EndpointInfoWarehouseTypeClassic EndpointInfoWarehouseType = `CLASSIC` - -const EndpointInfoWarehouseTypePro EndpointInfoWarehouseType = `PRO` - -const EndpointInfoWarehouseTypeTypeUnspecified EndpointInfoWarehouseType = `TYPE_UNSPECIFIED` - -// String representation for [fmt.Print] -func (eiwt *EndpointInfoWarehouseType) String() string { - return string(*eiwt) -} - -// Set raw string value and validate it against allowed values -func (eiwt *EndpointInfoWarehouseType) Set(v string) error { - switch v { - case `CLASSIC`, `PRO`, `TYPE_UNSPECIFIED`: - *eiwt = EndpointInfoWarehouseType(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "CLASSIC", "PRO", "TYPE_UNSPECIFIED"`, v) - } -} - -// Type always returns EndpointInfoWarehouseType to satisfy [pflag.Value] interface -func (eiwt *EndpointInfoWarehouseType) Type() string { - return "EndpointInfoWarehouseType" + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` } type EndpointTagPair struct { @@ -1018,127 +728,17 @@ type GetWarehouseResponse struct { NumClusters int `json:"num_clusters,omitempty"` // ODBC parameters for the sql endpoint OdbcParams *OdbcParams `json:"odbc_params,omitempty"` - // Configurations whether the endpoint should use spot instances. - // - // Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" - // - // Defaults to COST_OPTIMIZED. - // - // Please refer to documentation for EndpointSpotInstancePolicy for more - // details. - SpotInstancePolicy GetWarehouseResponseSpotInstancePolicy `json:"spot_instance_policy,omitempty"` - // state of the endpoint - State GetWarehouseResponseState `json:"state,omitempty"` + // Configurations whether the warehouse should use spot instances. + SpotInstancePolicy SpotInstancePolicy `json:"spot_instance_policy,omitempty"` + // State of the warehouse + State State `json:"state,omitempty"` // A set of key-value pairs that will be tagged on all resources (e.g., AWS // instances and EBS volumes) associated with this SQL Endpoints. // // Supported values: - Number of tags < 45. Tags *EndpointTags `json:"tags,omitempty"` - // Warehouse type (Classic/Pro) - WarehouseType GetWarehouseResponseWarehouseType `json:"warehouse_type,omitempty"` -} - -// Configurations whether the endpoint should use spot instances. -// -// Supported values: "COST_OPTIMIZED", "RELIABILITY_OPTIMIZED" -// -// Defaults to COST_OPTIMIZED. -// -// Please refer to documentation for EndpointSpotInstancePolicy for more -// details. -type GetWarehouseResponseSpotInstancePolicy string - -const GetWarehouseResponseSpotInstancePolicyCostOptimized GetWarehouseResponseSpotInstancePolicy = `COST_OPTIMIZED` - -const GetWarehouseResponseSpotInstancePolicyPolicyUnspecified GetWarehouseResponseSpotInstancePolicy = `POLICY_UNSPECIFIED` -const GetWarehouseResponseSpotInstancePolicyReliabilityOptimized GetWarehouseResponseSpotInstancePolicy = `RELIABILITY_OPTIMIZED` - -// String representation for [fmt.Print] -func (gwrsip *GetWarehouseResponseSpotInstancePolicy) String() string { - return string(*gwrsip) -} - -// Set raw string value and validate it against allowed values -func (gwrsip *GetWarehouseResponseSpotInstancePolicy) Set(v string) error { - switch v { - case `COST_OPTIMIZED`, `POLICY_UNSPECIFIED`, `RELIABILITY_OPTIMIZED`: - *gwrsip = GetWarehouseResponseSpotInstancePolicy(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED"`, v) - } -} - -// Type always returns GetWarehouseResponseSpotInstancePolicy to satisfy [pflag.Value] interface -func (gwrsip *GetWarehouseResponseSpotInstancePolicy) Type() string { - return "GetWarehouseResponseSpotInstancePolicy" -} - -// state of the endpoint -type GetWarehouseResponseState string - -const GetWarehouseResponseStateDeleted GetWarehouseResponseState = `DELETED` - -const GetWarehouseResponseStateDeleting GetWarehouseResponseState = `DELETING` - -const GetWarehouseResponseStateRunning GetWarehouseResponseState = `RUNNING` - -const GetWarehouseResponseStateStarting GetWarehouseResponseState = `STARTING` - -const GetWarehouseResponseStateStopped GetWarehouseResponseState = `STOPPED` - -const GetWarehouseResponseStateStopping GetWarehouseResponseState = `STOPPING` - -// String representation for [fmt.Print] -func (gwrs *GetWarehouseResponseState) String() string { - return string(*gwrs) -} - -// Set raw string value and validate it against allowed values -func (gwrs *GetWarehouseResponseState) Set(v string) error { - switch v { - case `DELETED`, `DELETING`, `RUNNING`, `STARTING`, `STOPPED`, `STOPPING`: - *gwrs = GetWarehouseResponseState(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "DELETED", "DELETING", "RUNNING", "STARTING", "STOPPED", "STOPPING"`, v) - } -} - -// Type always returns GetWarehouseResponseState to satisfy [pflag.Value] interface -func (gwrs *GetWarehouseResponseState) Type() string { - return "GetWarehouseResponseState" -} - -// Warehouse type (Classic/Pro) -type GetWarehouseResponseWarehouseType string - -const GetWarehouseResponseWarehouseTypeClassic GetWarehouseResponseWarehouseType = `CLASSIC` - -const GetWarehouseResponseWarehouseTypePro GetWarehouseResponseWarehouseType = `PRO` - -const GetWarehouseResponseWarehouseTypeTypeUnspecified GetWarehouseResponseWarehouseType = `TYPE_UNSPECIFIED` - -// String representation for [fmt.Print] -func (gwrwt *GetWarehouseResponseWarehouseType) String() string { - return string(*gwrwt) -} - -// Set raw string value and validate it against allowed values -func (gwrwt *GetWarehouseResponseWarehouseType) Set(v string) error { - switch v { - case `CLASSIC`, `PRO`, `TYPE_UNSPECIFIED`: - *gwrwt = GetWarehouseResponseWarehouseType(v) - return nil - default: - return fmt.Errorf(`value "%s" is not one of "CLASSIC", "PRO", "TYPE_UNSPECIFIED"`, v) - } -} - -// Type always returns GetWarehouseResponseWarehouseType to satisfy [pflag.Value] interface -func (gwrwt *GetWarehouseResponseWarehouseType) Type() string { - return "GetWarehouseResponseWarehouseType" + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` } type GetWorkspaceWarehouseConfigResponse struct { @@ -1990,12 +1590,110 @@ func (swwcrsp *SetWorkspaceWarehouseConfigRequestSecurityPolicy) Type() string { return "SetWorkspaceWarehouseConfigRequestSecurityPolicy" } +// Configurations whether the warehouse should use spot instances. +type SpotInstancePolicy string + +const SpotInstancePolicyCostOptimized SpotInstancePolicy = `COST_OPTIMIZED` + +const SpotInstancePolicyPolicyUnspecified SpotInstancePolicy = `POLICY_UNSPECIFIED` + +const SpotInstancePolicyReliabilityOptimized SpotInstancePolicy = `RELIABILITY_OPTIMIZED` + +// String representation for [fmt.Print] +func (sip *SpotInstancePolicy) String() string { + return string(*sip) +} + +// Set raw string value and validate it against allowed values +func (sip *SpotInstancePolicy) Set(v string) error { + switch v { + case `COST_OPTIMIZED`, `POLICY_UNSPECIFIED`, `RELIABILITY_OPTIMIZED`: + *sip = SpotInstancePolicy(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "COST_OPTIMIZED", "POLICY_UNSPECIFIED", "RELIABILITY_OPTIMIZED"`, v) + } +} + +// Type always returns SpotInstancePolicy to satisfy [pflag.Value] interface +func (sip *SpotInstancePolicy) Type() string { + return "SpotInstancePolicy" +} + // Start a warehouse type StartRequest struct { // Required. Id of the SQL warehouse. Id string `json:"-" url:"-"` } +// State of the warehouse +type State string + +const StateDeleted State = `DELETED` + +const StateDeleting State = `DELETING` + +const StateRunning State = `RUNNING` + +const StateStarting State = `STARTING` + +const StateStopped State = `STOPPED` + +const StateStopping State = `STOPPING` + +// String representation for [fmt.Print] +func (s *State) String() string { + return string(*s) +} + +// Set raw string value and validate it against allowed values +func (s *State) Set(v string) error { + switch v { + case `DELETED`, `DELETING`, `RUNNING`, `STARTING`, `STOPPED`, `STOPPING`: + *s = State(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DELETED", "DELETING", "RUNNING", "STARTING", "STOPPED", "STOPPING"`, v) + } +} + +// Type always returns State to satisfy [pflag.Value] interface +func (s *State) Type() string { + return "State" +} + +// Health status of the endpoint. +type Status string + +const StatusDegraded Status = `DEGRADED` + +const StatusFailed Status = `FAILED` + +const StatusHealthy Status = `HEALTHY` + +const StatusStatusUnspecified Status = `STATUS_UNSPECIFIED` + +// String representation for [fmt.Print] +func (s *Status) String() string { + return string(*s) +} + +// Set raw string value and validate it against allowed values +func (s *Status) Set(v string) error { + switch v { + case `DEGRADED`, `FAILED`, `HEALTHY`, `STATUS_UNSPECIFIED`: + *s = Status(v) + return nil + default: + return fmt.Errorf(`value "%s" is not one of "DEGRADED", "FAILED", "HEALTHY", "STATUS_UNSPECIFIED"`, v) + } +} + +// Type always returns Status to satisfy [pflag.Value] interface +func (s *Status) Type() string { + return "Status" +} + // Stop a warehouse type StopRequest struct { // Required. Id of the SQL warehouse. @@ -2336,41 +2034,41 @@ type Visualization struct { UpdatedAt string `json:"updated_at,omitempty"` } -type WarehouseTypePair struct { - // If set to false the specific warehouse type will not be be allowed as a - // value for warehouse_type in CreateWarehouse and EditWarehouse - Enabled bool `json:"enabled,omitempty"` - - WarehouseType WarehouseTypePairWarehouseType `json:"warehouse_type,omitempty"` -} - -type WarehouseTypePairWarehouseType string +type WarehouseType string -const WarehouseTypePairWarehouseTypeClassic WarehouseTypePairWarehouseType = `CLASSIC` +const WarehouseTypeClassic WarehouseType = `CLASSIC` -const WarehouseTypePairWarehouseTypePro WarehouseTypePairWarehouseType = `PRO` +const WarehouseTypePro WarehouseType = `PRO` -const WarehouseTypePairWarehouseTypeTypeUnspecified WarehouseTypePairWarehouseType = `TYPE_UNSPECIFIED` +const WarehouseTypeTypeUnspecified WarehouseType = `TYPE_UNSPECIFIED` // String representation for [fmt.Print] -func (wtpwt *WarehouseTypePairWarehouseType) String() string { - return string(*wtpwt) +func (wt *WarehouseType) String() string { + return string(*wt) } // Set raw string value and validate it against allowed values -func (wtpwt *WarehouseTypePairWarehouseType) Set(v string) error { +func (wt *WarehouseType) Set(v string) error { switch v { case `CLASSIC`, `PRO`, `TYPE_UNSPECIFIED`: - *wtpwt = WarehouseTypePairWarehouseType(v) + *wt = WarehouseType(v) return nil default: return fmt.Errorf(`value "%s" is not one of "CLASSIC", "PRO", "TYPE_UNSPECIFIED"`, v) } } -// Type always returns WarehouseTypePairWarehouseType to satisfy [pflag.Value] interface -func (wtpwt *WarehouseTypePairWarehouseType) Type() string { - return "WarehouseTypePairWarehouseType" +// Type always returns WarehouseType to satisfy [pflag.Value] interface +func (wt *WarehouseType) Type() string { + return "WarehouseType" +} + +type WarehouseTypePair struct { + // If set to false the specific warehouse type will not be be allowed as a + // value for warehouse_type in CreateWarehouse and EditWarehouse + Enabled bool `json:"enabled,omitempty"` + + WarehouseType WarehouseType `json:"warehouse_type,omitempty"` } type Widget struct { From 2c066b245ec9d4d245b03fe986557c1acc73d3c4 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Sat, 10 Dec 2022 18:45:17 +0100 Subject: [PATCH 3/4] consistency pass --- service/tokenmanagement/api.go | 28 ++++++++++++++-------------- service/tokenmanagement/impl.go | 6 +++--- service/tokenmanagement/interface.go | 8 ++++---- service/tokenmanagement/model.go | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/service/tokenmanagement/api.go b/service/tokenmanagement/api.go index 21c3cc2d1..7e85db59e 100755 --- a/service/tokenmanagement/api.go +++ b/service/tokenmanagement/api.go @@ -50,15 +50,15 @@ func (a *TokenManagementAPI) CreateOboToken(ctx context.Context, request CreateO // Delete a token. // // Deletes a token, specified by its ID. -func (a *TokenManagementAPI) DeleteToken(ctx context.Context, request DeleteToken) error { - return a.impl.DeleteToken(ctx, request) +func (a *TokenManagementAPI) Delete(ctx context.Context, request Delete) error { + return a.impl.Delete(ctx, request) } // Delete a token. // // Deletes a token, specified by its ID. -func (a *TokenManagementAPI) DeleteTokenByTokenId(ctx context.Context, tokenId string) error { - return a.impl.DeleteToken(ctx, DeleteToken{ +func (a *TokenManagementAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { + return a.impl.Delete(ctx, Delete{ TokenId: tokenId, }) } @@ -66,15 +66,15 @@ func (a *TokenManagementAPI) DeleteTokenByTokenId(ctx context.Context, tokenId s // Get token info. // // Gets information about a token, specified by its ID. -func (a *TokenManagementAPI) GetTokenInfo(ctx context.Context, request GetTokenInfo) (*TokenInfo, error) { - return a.impl.GetTokenInfo(ctx, request) +func (a *TokenManagementAPI) Get(ctx context.Context, request Get) (*TokenInfo, error) { + return a.impl.Get(ctx, request) } // Get token info. // // Gets information about a token, specified by its ID. -func (a *TokenManagementAPI) GetTokenInfoByTokenId(ctx context.Context, tokenId string) (*TokenInfo, error) { - return a.impl.GetTokenInfo(ctx, GetTokenInfo{ +func (a *TokenManagementAPI) GetByTokenId(ctx context.Context, tokenId string) (*TokenInfo, error) { + return a.impl.Get(ctx, Get{ TokenId: tokenId, }) } @@ -84,25 +84,25 @@ func (a *TokenManagementAPI) GetTokenInfoByTokenId(ctx context.Context, tokenId // Lists all tokens associated with the specified workspace or user. // // This method is generated by Databricks SDK Code Generator. -func (a *TokenManagementAPI) ListTokensAll(ctx context.Context, request ListTokens) ([]TokenInfo, error) { - response, err := a.impl.ListTokens(ctx, request) +func (a *TokenManagementAPI) ListAll(ctx context.Context, request List) ([]TokenInfo, error) { + response, err := a.impl.List(ctx, request) if err != nil { return nil, err } return response.TokenInfos, nil } -// TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListTokensAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. +// TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. // // Returns an error if there's more than one [TokenInfo] with the same .Comment. // // Note: All [TokenInfo] instances are loaded into memory before creating a map. // // This method is generated by Databricks SDK Code Generator. -func (a *TokenManagementAPI) TokenInfoCommentToTokenIdMap(ctx context.Context, request ListTokens) (map[string]string, error) { +func (a *TokenManagementAPI) TokenInfoCommentToTokenIdMap(ctx context.Context, request List) (map[string]string, error) { ctx = useragent.InContext(ctx, "sdk-feature", "name-to-id") mapping := map[string]string{} - result, err := a.ListTokensAll(ctx, request) + result, err := a.ListAll(ctx, request) if err != nil { return nil, err } @@ -126,7 +126,7 @@ func (a *TokenManagementAPI) TokenInfoCommentToTokenIdMap(ctx context.Context, r // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) GetByComment(ctx context.Context, name string) (*TokenInfo, error) { ctx = useragent.InContext(ctx, "sdk-feature", "get-by-name") - result, err := a.ListTokensAll(ctx, ListTokens{}) + result, err := a.ListAll(ctx, List{}) if err != nil { return nil, err } diff --git a/service/tokenmanagement/impl.go b/service/tokenmanagement/impl.go index 345f180fd..f86acbb67 100755 --- a/service/tokenmanagement/impl.go +++ b/service/tokenmanagement/impl.go @@ -22,20 +22,20 @@ func (a *tokenManagementImpl) CreateOboToken(ctx context.Context, request Create return &createOboTokenResponse, err } -func (a *tokenManagementImpl) DeleteToken(ctx context.Context, request DeleteToken) error { +func (a *tokenManagementImpl) Delete(ctx context.Context, request Delete) error { path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) err := a.client.Do(ctx, http.MethodDelete, path, request, nil) return err } -func (a *tokenManagementImpl) GetTokenInfo(ctx context.Context, request GetTokenInfo) (*TokenInfo, error) { +func (a *tokenManagementImpl) Get(ctx context.Context, request Get) (*TokenInfo, error) { var tokenInfo TokenInfo path := fmt.Sprintf("/api/2.0/token-management/tokens/%v", request.TokenId) err := a.client.Do(ctx, http.MethodGet, path, request, &tokenInfo) return &tokenInfo, err } -func (a *tokenManagementImpl) ListTokens(ctx context.Context, request ListTokens) (*ListTokensResponse, error) { +func (a *tokenManagementImpl) List(ctx context.Context, request List) (*ListTokensResponse, error) { var listTokensResponse ListTokensResponse path := "/api/2.0/token-management/tokens" err := a.client.Do(ctx, http.MethodGet, path, request, &listTokensResponse) diff --git a/service/tokenmanagement/interface.go b/service/tokenmanagement/interface.go index 44218d9ec..f9aeab4b7 100755 --- a/service/tokenmanagement/interface.go +++ b/service/tokenmanagement/interface.go @@ -19,17 +19,17 @@ type TokenManagementService interface { // Delete a token. // // Deletes a token, specified by its ID. - DeleteToken(ctx context.Context, request DeleteToken) error + Delete(ctx context.Context, request Delete) error // Get token info. // // Gets information about a token, specified by its ID. - GetTokenInfo(ctx context.Context, request GetTokenInfo) (*TokenInfo, error) + Get(ctx context.Context, request Get) (*TokenInfo, error) // List all tokens. // // Lists all tokens associated with the specified workspace or user. // - // Use ListTokensAll() to get all TokenInfo instances - ListTokens(ctx context.Context, request ListTokens) (*ListTokensResponse, error) + // Use ListAll() to get all TokenInfo instances + List(ctx context.Context, request List) (*ListTokensResponse, error) } diff --git a/service/tokenmanagement/model.go b/service/tokenmanagement/model.go index 45b2fb0ae..00bbccdec 100755 --- a/service/tokenmanagement/model.go +++ b/service/tokenmanagement/model.go @@ -20,19 +20,19 @@ type CreateOboTokenResponse struct { } // Delete a token -type DeleteToken struct { +type Delete struct { // The ID of the token to get. TokenId string `json:"-" url:"-"` } // Get token info -type GetTokenInfo struct { +type Get struct { // The ID of the token to get. TokenId string `json:"-" url:"-"` } // List all tokens -type ListTokens struct { +type List struct { // User ID of the user that created the token. CreatedById string `json:"-" url:"created_by_id,omitempty"` // Username of the user that created the token. From 5896432334f89d385954f99f596a4113e0de84a8 Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Sat, 10 Dec 2022 19:57:25 +0100 Subject: [PATCH 4/4] fix --- service/unitycatalog/model.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/service/unitycatalog/model.go b/service/unitycatalog/model.go index a84a4d4ff..2e1c09f84 100755 --- a/service/unitycatalog/model.go +++ b/service/unitycatalog/model.go @@ -948,6 +948,8 @@ type ShareInfo struct { Name string `json:"name,omitempty"` // A list of shared data objects within the Share. Objects []SharedDataObject `json:"objects,omitempty"` + // Username of current owner of credential. + Owner string `json:"owner,omitempty"` } // Get share permissions