Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): Update backend common code and integration tests with updated API Service Params #10640

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions backend/src/common/client/api_server/v1/experiment_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import (
)

type ExperimentInterface interface {
Create(params *params.CreateExperimentV1Params) (*model.APIExperiment, error)
Get(params *params.GetExperimentV1Params) (*model.APIExperiment, error)
List(params *params.ListExperimentsV1Params) ([]*model.APIExperiment, int, string, error)
ListAll(params *params.ListExperimentsV1Params, maxResultSize int) ([]*model.APIExperiment, error)
Archive(params *params.ArchiveExperimentV1Params) error
Unarchive(params *params.UnarchiveExperimentV1Params) error
Create(params *params.ExperimentServiceCreateExperimentV1Params) (*model.APIExperiment, error)
Get(params *params.ExperimentServiceGetExperimentV1Params) (*model.APIExperiment, error)
List(params *params.ExperimentServiceListExperimentsV1Params) ([]*model.APIExperiment, int, string, error)
ListAll(params *params.ExperimentServiceListExperimentsV1Params, maxResultSize int) ([]*model.APIExperiment, error)
Archive(params *params.ExperimentServiceArchiveExperimentV1Params) error
Unarchive(params *params.ExperimentServiceUnarchiveExperimentV1Params) error
}

type ExperimentClient struct {
Expand Down Expand Up @@ -74,17 +74,17 @@ func NewKubeflowInClusterExperimentClient(namespace string, debug bool) (
}, nil
}

func (c *ExperimentClient) Create(parameters *params.CreateExperimentV1Params) (*model.APIExperiment,
func (c *ExperimentClient) Create(parameters *params.ExperimentServiceCreateExperimentV1Params) (*model.APIExperiment,
error) {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
response, err := c.apiClient.ExperimentService.CreateExperimentV1(parameters, c.authInfoWriter)
response, err := c.apiClient.ExperimentService.ExperimentServiceCreateExperimentV1(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.CreateExperimentV1Default); ok {
if defaultError, ok := err.(*params.ExperimentServiceCreateExperimentV1Default); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -98,17 +98,17 @@ func (c *ExperimentClient) Create(parameters *params.CreateExperimentV1Params) (
return response.Payload, nil
}

func (c *ExperimentClient) Get(parameters *params.GetExperimentV1Params) (*model.APIExperiment,
func (c *ExperimentClient) Get(parameters *params.ExperimentServiceGetExperimentV1Params) (*model.APIExperiment,
error) {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
response, err := c.apiClient.ExperimentService.GetExperimentV1(parameters, c.authInfoWriter)
response, err := c.apiClient.ExperimentService.ExperimentServiceGetExperimentV1(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.GetExperimentV1Default); ok {
if defaultError, ok := err.(*params.ExperimentServiceGetExperimentV1Default); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -122,17 +122,17 @@ func (c *ExperimentClient) Get(parameters *params.GetExperimentV1Params) (*model
return response.Payload, nil
}

func (c *ExperimentClient) List(parameters *params.ListExperimentsV1Params) (
func (c *ExperimentClient) List(parameters *params.ExperimentServiceListExperimentsV1Params) (
[]*model.APIExperiment, int, string, error) {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
response, err := c.apiClient.ExperimentService.ListExperimentsV1(parameters, c.authInfoWriter)
response, err := c.apiClient.ExperimentService.ExperimentServiceListExperimentsV1(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.ListExperimentsV1Default); ok {
if defaultError, ok := err.(*params.ExperimentServiceListExperimentsV1Default); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -146,16 +146,16 @@ func (c *ExperimentClient) List(parameters *params.ListExperimentsV1Params) (
return response.Payload.Experiments, int(response.Payload.TotalSize), response.Payload.NextPageToken, nil
}

func (c *ExperimentClient) Delete(parameters *params.DeleteExperimentV1Params) error {
func (c *ExperimentClient) Delete(parameters *params.ExperimentServiceDeleteExperimentV1Params) error {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
_, err := c.apiClient.ExperimentService.DeleteExperimentV1(parameters, c.authInfoWriter)
_, err := c.apiClient.ExperimentService.ExperimentServiceDeleteExperimentV1(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.DeleteExperimentV1Default); ok {
if defaultError, ok := err.(*params.ExperimentServiceDeleteExperimentV1Default); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -169,12 +169,12 @@ func (c *ExperimentClient) Delete(parameters *params.DeleteExperimentV1Params) e
return nil
}

func (c *ExperimentClient) ListAll(parameters *params.ListExperimentsV1Params, maxResultSize int) (
func (c *ExperimentClient) ListAll(parameters *params.ExperimentServiceListExperimentsV1Params, maxResultSize int) (
[]*model.APIExperiment, error) {
return listAllForExperiment(c, parameters, maxResultSize)
}

func listAllForExperiment(client ExperimentInterface, parameters *params.ListExperimentsV1Params,
func listAllForExperiment(client ExperimentInterface, parameters *params.ExperimentServiceListExperimentsV1Params,
maxResultSize int) ([]*model.APIExperiment, error) {
if maxResultSize < 0 {
maxResultSize = 0
Expand All @@ -199,17 +199,17 @@ func listAllForExperiment(client ExperimentInterface, parameters *params.ListExp
return allResults, nil
}

func (c *ExperimentClient) Archive(parameters *params.ArchiveExperimentV1Params) error {
func (c *ExperimentClient) Archive(parameters *params.ExperimentServiceArchiveExperimentV1Params) error {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
_, err := c.apiClient.ExperimentService.ArchiveExperimentV1(parameters, c.authInfoWriter)
_, err := c.apiClient.ExperimentService.ExperimentServiceArchiveExperimentV1(parameters, c.authInfoWriter)

if err != nil {
if defaultError, ok := err.(*params.ArchiveExperimentV1Default); ok {
if defaultError, ok := err.(*params.ExperimentServiceArchiveExperimentV1Default); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -223,17 +223,17 @@ func (c *ExperimentClient) Archive(parameters *params.ArchiveExperimentV1Params)
return nil
}

func (c *ExperimentClient) Unarchive(parameters *params.UnarchiveExperimentV1Params) error {
func (c *ExperimentClient) Unarchive(parameters *params.ExperimentServiceUnarchiveExperimentV1Params) error {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
_, err := c.apiClient.ExperimentService.UnarchiveExperimentV1(parameters, c.authInfoWriter)
_, err := c.apiClient.ExperimentService.ExperimentServiceUnarchiveExperimentV1(parameters, c.authInfoWriter)

if err != nil {
if defaultError, ok := err.(*params.UnarchiveExperimentV1Default); ok {
if defaultError, ok := err.(*params.ExperimentServiceUnarchiveExperimentV1Default); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewExperimentClientFake() *ExperimentClientFake {
return &ExperimentClientFake{}
}

func (c *ExperimentClientFake) Create(params *experimentparams.CreateExperimentV1Params) (
func (c *ExperimentClientFake) Create(params *experimentparams.ExperimentServiceCreateExperimentV1Params) (
*experimentmodel.APIExperiment, error) {
switch params.Body.Name {
case ExperimentForClientErrorTest:
Expand All @@ -51,7 +51,7 @@ func (c *ExperimentClientFake) Create(params *experimentparams.CreateExperimentV
}
}

func (c *ExperimentClientFake) Get(params *experimentparams.GetExperimentV1Params) (
func (c *ExperimentClientFake) Get(params *experimentparams.ExperimentServiceGetExperimentV1Params) (
*experimentmodel.APIExperiment, error) {
switch params.ID {
case ExperimentForClientErrorTest:
Expand All @@ -61,7 +61,7 @@ func (c *ExperimentClientFake) Get(params *experimentparams.GetExperimentV1Param
}
}

func (c *ExperimentClientFake) List(params *experimentparams.ListExperimentsV1Params) (
func (c *ExperimentClientFake) List(params *experimentparams.ExperimentServiceListExperimentsV1Params) (
[]*experimentmodel.APIExperiment, int, string, error) {
const (
FirstToken = ""
Expand Down Expand Up @@ -89,15 +89,15 @@ func (c *ExperimentClientFake) List(params *experimentparams.ListExperimentsV1Pa
}
}

func (c *ExperimentClientFake) ListAll(params *experimentparams.ListExperimentsV1Params,
func (c *ExperimentClientFake) ListAll(params *experimentparams.ExperimentServiceListExperimentsV1Params,
maxResultSize int) ([]*experimentmodel.APIExperiment, error) {
return listAllForExperiment(c, params, maxResultSize)
}

func (c *ExperimentClientFake) Archive(params *experimentparams.ArchiveExperimentV1Params) error {
func (c *ExperimentClientFake) Archive(params *experimentparams.ExperimentServiceArchiveExperimentV1Params) error {
return nil
}

func (c *ExperimentClientFake) Unarchive(params *experimentparams.UnarchiveExperimentV1Params) error {
func (c *ExperimentClientFake) Unarchive(params *experimentparams.ExperimentServiceUnarchiveExperimentV1Params) error {
return nil
}
8 changes: 4 additions & 4 deletions backend/src/common/client/api_server/v1/healthz_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

type HealthzInterface interface {
GetHealthz() (*params.GetHealthzOK, error)
GetHealthz() (*params.HealthzServiceGetHealthzOK, error)
}

type HealthzClient struct {
Expand Down Expand Up @@ -65,10 +65,10 @@ func NewKubeflowInClusterHealthzClient(namespace string, debug bool) (
}

func (c *HealthzClient) GetHealthz() (*model.APIGetHealthzResponse, error) {
parameters := params.NewGetHealthzParamsWithTimeout(api_server.APIServerDefaultTimeout)
response, err := c.apiClient.HealthzService.GetHealthz(parameters, api_server.PassThroughAuth)
parameters := params.NewHealthzServiceGetHealthzParamsWithTimeout(api_server.APIServerDefaultTimeout)
response, err := c.apiClient.HealthzService.HealthzServiceGetHealthz(parameters, api_server.PassThroughAuth)
if err != nil {
if defaultError, ok := err.(*params.GetHealthzDefault); ok {
if defaultError, ok := err.(*params.HealthzServiceGetHealthzDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand Down
54 changes: 27 additions & 27 deletions backend/src/common/client/api_server/v1/job_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import (
)

type JobInterface interface {
Create(params *params.CreateJobParams) (*model.APIJob, error)
Get(params *params.GetJobParams) (*model.APIJob, error)
Delete(params *params.DeleteJobParams) error
Enable(params *params.EnableJobParams) error
Disable(params *params.DisableJobParams) error
List(params *params.ListJobsParams) ([]*model.APIJob, int, string, error)
ListAll(params *params.ListJobsParams, maxResultSize int) ([]*model.APIJob, error)
Create(params *params.JobServiceCreateJobParams) (*model.APIJob, error)
Get(params *params.JobServiceGetJobParams) (*model.APIJob, error)
Delete(params *params.JobServiceDeleteJobParams) error
Enable(params *params.JobServiceEnableJobParams) error
Disable(params *params.JobServiceDisableJobParams) error
List(params *params.JobServiceListJobsParams) ([]*model.APIJob, int, string, error)
ListAll(params *params.JobServiceListJobsParams, maxResultSize int) ([]*model.APIJob, error)
}

type JobClient struct {
Expand Down Expand Up @@ -74,17 +74,17 @@ func NewKubeflowInClusterJobClient(namespace string, debug bool) (
}, nil
}

func (c *JobClient) Create(parameters *params.CreateJobParams) (*model.APIJob,
func (c *JobClient) Create(parameters *params.JobServiceCreateJobParams) (*model.APIJob,
error) {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
response, err := c.apiClient.JobService.CreateJob(parameters, c.authInfoWriter)
response, err := c.apiClient.JobService.JobServiceCreateJob(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.CreateJobDefault); ok {
if defaultError, ok := err.(*params.JobServiceCreateJobDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -98,17 +98,17 @@ func (c *JobClient) Create(parameters *params.CreateJobParams) (*model.APIJob,
return response.Payload, nil
}

func (c *JobClient) Get(parameters *params.GetJobParams) (*model.APIJob,
func (c *JobClient) Get(parameters *params.JobServiceGetJobParams) (*model.APIJob,
error) {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
response, err := c.apiClient.JobService.GetJob(parameters, c.authInfoWriter)
response, err := c.apiClient.JobService.JobServiceGetJob(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.GetJobDefault); ok {
if defaultError, ok := err.(*params.JobServiceGetJobDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -122,16 +122,16 @@ func (c *JobClient) Get(parameters *params.GetJobParams) (*model.APIJob,
return response.Payload, nil
}

func (c *JobClient) Delete(parameters *params.DeleteJobParams) error {
func (c *JobClient) Delete(parameters *params.JobServiceDeleteJobParams) error {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
_, err := c.apiClient.JobService.DeleteJob(parameters, c.authInfoWriter)
_, err := c.apiClient.JobService.JobServiceDeleteJob(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.DeleteJobDefault); ok {
if defaultError, ok := err.(*params.JobServiceDeleteJobDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -145,16 +145,16 @@ func (c *JobClient) Delete(parameters *params.DeleteJobParams) error {
return nil
}

func (c *JobClient) Enable(parameters *params.EnableJobParams) error {
func (c *JobClient) Enable(parameters *params.JobServiceEnableJobParams) error {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
_, err := c.apiClient.JobService.EnableJob(parameters, c.authInfoWriter)
_, err := c.apiClient.JobService.JobServiceEnableJob(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.EnableJobDefault); ok {
if defaultError, ok := err.(*params.JobServiceEnableJobDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -168,16 +168,16 @@ func (c *JobClient) Enable(parameters *params.EnableJobParams) error {
return nil
}

func (c *JobClient) Disable(parameters *params.DisableJobParams) error {
func (c *JobClient) Disable(parameters *params.JobServiceDisableJobParams) error {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
_, err := c.apiClient.JobService.DisableJob(parameters, c.authInfoWriter)
_, err := c.apiClient.JobService.JobServiceDisableJob(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.DisableJobDefault); ok {
if defaultError, ok := err.(*params.JobServiceDisableJobDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -191,17 +191,17 @@ func (c *JobClient) Disable(parameters *params.DisableJobParams) error {
return nil
}

func (c *JobClient) List(parameters *params.ListJobsParams) (
func (c *JobClient) List(parameters *params.JobServiceListJobsParams) (
[]*model.APIJob, int, string, error) {
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), api_server.APIServerDefaultTimeout)
defer cancel()

// Make service call
parameters.Context = ctx
response, err := c.apiClient.JobService.ListJobs(parameters, c.authInfoWriter)
response, err := c.apiClient.JobService.JobServiceListJobs(parameters, c.authInfoWriter)
if err != nil {
if defaultError, ok := err.(*params.ListJobsDefault); ok {
if defaultError, ok := err.(*params.JobServiceListJobsDefault); ok {
err = api_server.CreateErrorFromAPIStatus(defaultError.Payload.Error, defaultError.Payload.Code)
} else {
err = api_server.CreateErrorCouldNotRecoverAPIStatus(err)
Expand All @@ -215,12 +215,12 @@ func (c *JobClient) List(parameters *params.ListJobsParams) (
return response.Payload.Jobs, int(response.Payload.TotalSize), response.Payload.NextPageToken, nil
}

func (c *JobClient) ListAll(parameters *params.ListJobsParams, maxResultSize int) (
func (c *JobClient) ListAll(parameters *params.JobServiceListJobsParams, maxResultSize int) (
[]*model.APIJob, error) {
return listAllForJob(c, parameters, maxResultSize)
}

func listAllForJob(client JobInterface, parameters *params.ListJobsParams,
func listAllForJob(client JobInterface, parameters *params.JobServiceListJobsParams,
maxResultSize int) ([]*model.APIJob, error) {
if maxResultSize < 0 {
maxResultSize = 0
Expand Down
Loading