From 5fdd3827d647f6978de46fd60025639277140021 Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Fri, 7 Feb 2020 10:12:02 +0000 Subject: [PATCH] Swagger generated code for UploadPipelineVersion method --- .../pipeline_upload_service/BUILD.bazel | 2 + .../pipeline_upload_service_client.go | 29 +++ .../upload_pipeline_version_parameters.go | 179 +++++++++++++++++ .../upload_pipeline_version_responses.go | 126 ++++++++++++ .../pipeline_upload_model/BUILD.bazel | 5 + .../api_pipeline_version.go | 185 ++++++++++++++++++ .../pipeline_upload_model/api_relationship.go | 80 ++++++++ .../pipeline_upload_model/api_resource_key.go | 86 ++++++++ .../api_resource_reference.go | 111 +++++++++++ .../api_resource_type.go | 89 +++++++++ 10 files changed, 892 insertions(+) create mode 100644 backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_parameters.go create mode 100644 backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_responses.go create mode 100644 backend/api/go_http_client/pipeline_upload_model/api_pipeline_version.go create mode 100644 backend/api/go_http_client/pipeline_upload_model/api_relationship.go create mode 100644 backend/api/go_http_client/pipeline_upload_model/api_resource_key.go create mode 100644 backend/api/go_http_client/pipeline_upload_model/api_resource_reference.go create mode 100644 backend/api/go_http_client/pipeline_upload_model/api_resource_type.go diff --git a/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/BUILD.bazel b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/BUILD.bazel index be540f87e57..67db66690db 100644 --- a/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/BUILD.bazel +++ b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/BUILD.bazel @@ -6,6 +6,8 @@ go_library( "pipeline_upload_service_client.go", "upload_pipeline_parameters.go", "upload_pipeline_responses.go", + "upload_pipeline_version_parameters.go", + "upload_pipeline_version_responses.go", ], importpath = "github.com/kubeflow/pipelines/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service", visibility = ["//visibility:public"], diff --git a/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/pipeline_upload_service_client.go b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/pipeline_upload_service_client.go index 50f56e4a9a0..35712772518 100644 --- a/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/pipeline_upload_service_client.go +++ b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/pipeline_upload_service_client.go @@ -67,6 +67,35 @@ func (a *Client) UploadPipeline(params *UploadPipelineParams, authInfo runtime.C } +/* +UploadPipelineVersion upload pipeline version API +*/ +func (a *Client) UploadPipelineVersion(params *UploadPipelineVersionParams, authInfo runtime.ClientAuthInfoWriter) (*UploadPipelineVersionOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUploadPipelineVersionParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "UploadPipelineVersion", + Method: "POST", + PathPattern: "/apis/v1beta1/pipelines/upload_version", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"multipart/form-data"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &UploadPipelineVersionReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*UploadPipelineVersionOK), nil + +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_parameters.go b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_parameters.go new file mode 100644 index 00000000000..1958ea942e5 --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_parameters.go @@ -0,0 +1,179 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_service + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewUploadPipelineVersionParams creates a new UploadPipelineVersionParams object +// with the default values initialized. +func NewUploadPipelineVersionParams() *UploadPipelineVersionParams { + var () + return &UploadPipelineVersionParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewUploadPipelineVersionParamsWithTimeout creates a new UploadPipelineVersionParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewUploadPipelineVersionParamsWithTimeout(timeout time.Duration) *UploadPipelineVersionParams { + var () + return &UploadPipelineVersionParams{ + + timeout: timeout, + } +} + +// NewUploadPipelineVersionParamsWithContext creates a new UploadPipelineVersionParams object +// with the default values initialized, and the ability to set a context for a request +func NewUploadPipelineVersionParamsWithContext(ctx context.Context) *UploadPipelineVersionParams { + var () + return &UploadPipelineVersionParams{ + + Context: ctx, + } +} + +// NewUploadPipelineVersionParamsWithHTTPClient creates a new UploadPipelineVersionParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewUploadPipelineVersionParamsWithHTTPClient(client *http.Client) *UploadPipelineVersionParams { + var () + return &UploadPipelineVersionParams{ + HTTPClient: client, + } +} + +/*UploadPipelineVersionParams contains all the parameters to send to the API endpoint +for the upload pipeline version operation typically these are written to a http.Request +*/ +type UploadPipelineVersionParams struct { + + /*Name*/ + Name *string + /*Uploadfile + The pipeline to upload. Maximum size of 32MB is supported. + + */ + Uploadfile runtime.NamedReadCloser + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the upload pipeline version params +func (o *UploadPipelineVersionParams) WithTimeout(timeout time.Duration) *UploadPipelineVersionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the upload pipeline version params +func (o *UploadPipelineVersionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the upload pipeline version params +func (o *UploadPipelineVersionParams) WithContext(ctx context.Context) *UploadPipelineVersionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the upload pipeline version params +func (o *UploadPipelineVersionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the upload pipeline version params +func (o *UploadPipelineVersionParams) WithHTTPClient(client *http.Client) *UploadPipelineVersionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the upload pipeline version params +func (o *UploadPipelineVersionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithName adds the name to the upload pipeline version params +func (o *UploadPipelineVersionParams) WithName(name *string) *UploadPipelineVersionParams { + o.SetName(name) + return o +} + +// SetName adds the name to the upload pipeline version params +func (o *UploadPipelineVersionParams) SetName(name *string) { + o.Name = name +} + +// WithUploadfile adds the uploadfile to the upload pipeline version params +func (o *UploadPipelineVersionParams) WithUploadfile(uploadfile runtime.NamedReadCloser) *UploadPipelineVersionParams { + o.SetUploadfile(uploadfile) + return o +} + +// SetUploadfile adds the uploadfile to the upload pipeline version params +func (o *UploadPipelineVersionParams) SetUploadfile(uploadfile runtime.NamedReadCloser) { + o.Uploadfile = uploadfile +} + +// WriteToRequest writes these params to a swagger request +func (o *UploadPipelineVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Name != nil { + + // query param name + var qrName string + if o.Name != nil { + qrName = *o.Name + } + qName := qrName + if qName != "" { + if err := r.SetQueryParam("name", qName); err != nil { + return err + } + } + + } + + // form file param uploadfile + if err := r.SetFileParam("uploadfile", o.Uploadfile); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_responses.go b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_responses.go new file mode 100644 index 00000000000..a54d072b194 --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_client/pipeline_upload_service/upload_pipeline_version_responses.go @@ -0,0 +1,126 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_service + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" + + pipeline_upload_model "github.com/kubeflow/pipelines/backend/api/go_http_client/pipeline_upload_model" +) + +// UploadPipelineVersionReader is a Reader for the UploadPipelineVersion structure. +type UploadPipelineVersionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UploadPipelineVersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewUploadPipelineVersionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + result := NewUploadPipelineVersionDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewUploadPipelineVersionOK creates a UploadPipelineVersionOK with default headers values +func NewUploadPipelineVersionOK() *UploadPipelineVersionOK { + return &UploadPipelineVersionOK{} +} + +/*UploadPipelineVersionOK handles this case with default header values. + +UploadPipelineVersionOK upload pipeline version o k +*/ +type UploadPipelineVersionOK struct { + Payload *pipeline_upload_model.APIPipelineVersion +} + +func (o *UploadPipelineVersionOK) Error() string { + return fmt.Sprintf("[POST /apis/v1beta1/pipelines/upload_version][%d] uploadPipelineVersionOK %+v", 200, o.Payload) +} + +func (o *UploadPipelineVersionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(pipeline_upload_model.APIPipelineVersion) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUploadPipelineVersionDefault creates a UploadPipelineVersionDefault with default headers values +func NewUploadPipelineVersionDefault(code int) *UploadPipelineVersionDefault { + return &UploadPipelineVersionDefault{ + _statusCode: code, + } +} + +/*UploadPipelineVersionDefault handles this case with default header values. + +UploadPipelineVersionDefault upload pipeline version default +*/ +type UploadPipelineVersionDefault struct { + _statusCode int + + Payload *pipeline_upload_model.APIStatus +} + +// Code gets the status code for the upload pipeline version default response +func (o *UploadPipelineVersionDefault) Code() int { + return o._statusCode +} + +func (o *UploadPipelineVersionDefault) Error() string { + return fmt.Sprintf("[POST /apis/v1beta1/pipelines/upload_version][%d] UploadPipelineVersion default %+v", o._statusCode, o.Payload) +} + +func (o *UploadPipelineVersionDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(pipeline_upload_model.APIStatus) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/backend/api/go_http_client/pipeline_upload_model/BUILD.bazel b/backend/api/go_http_client/pipeline_upload_model/BUILD.bazel index 9ec28c79c7a..47139760513 100644 --- a/backend/api/go_http_client/pipeline_upload_model/BUILD.bazel +++ b/backend/api/go_http_client/pipeline_upload_model/BUILD.bazel @@ -5,6 +5,11 @@ go_library( srcs = [ "api_parameter.go", "api_pipeline.go", + "api_pipeline_version.go", + "api_relationship.go", + "api_resource_key.go", + "api_resource_reference.go", + "api_resource_type.go", "api_status.go", "api_url.go", "protobuf_any.go", diff --git a/backend/api/go_http_client/pipeline_upload_model/api_pipeline_version.go b/backend/api/go_http_client/pipeline_upload_model/api_pipeline_version.go new file mode 100644 index 00000000000..506a65b383c --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_model/api_pipeline_version.go @@ -0,0 +1,185 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// APIPipelineVersion api pipeline version +// swagger:model apiPipelineVersion +type APIPipelineVersion struct { + + // Input. Optional. Pipeline version code source. + CodeSourceURL string `json:"code_source_url,omitempty"` + + // Output. The time this pipeline version is created. + // Format: date-time + CreatedAt strfmt.DateTime `json:"created_at,omitempty"` + + // Output. Unique version ID. Generated by API server. + ID string `json:"id,omitempty"` + + // Optional input field. Version name provided by user. + Name string `json:"name,omitempty"` + + // Input. Required. Pipeline version package url. + // Whe calling CreatePipelineVersion API method, need to provide one package + // file location. + PackageURL *APIURL `json:"package_url,omitempty"` + + // Output. The input parameters for this pipeline. + Parameters []*APIParameter `json:"parameters"` + + // Input. Required. E.g., specify which pipeline this pipeline version belongs + // to. + ResourceReferences []*APIResourceReference `json:"resource_references"` +} + +// Validate validates this api pipeline version +func (m *APIPipelineVersion) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreatedAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePackageURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateParameters(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceReferences(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIPipelineVersion) validateCreatedAt(formats strfmt.Registry) error { + + if swag.IsZero(m.CreatedAt) { // not required + return nil + } + + if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *APIPipelineVersion) validatePackageURL(formats strfmt.Registry) error { + + if swag.IsZero(m.PackageURL) { // not required + return nil + } + + if m.PackageURL != nil { + if err := m.PackageURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("package_url") + } + return err + } + } + + return nil +} + +func (m *APIPipelineVersion) validateParameters(formats strfmt.Registry) error { + + if swag.IsZero(m.Parameters) { // not required + return nil + } + + for i := 0; i < len(m.Parameters); i++ { + if swag.IsZero(m.Parameters[i]) { // not required + continue + } + + if m.Parameters[i] != nil { + if err := m.Parameters[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("parameters" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIPipelineVersion) validateResourceReferences(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceReferences) { // not required + return nil + } + + for i := 0; i < len(m.ResourceReferences); i++ { + if swag.IsZero(m.ResourceReferences[i]) { // not required + continue + } + + if m.ResourceReferences[i] != nil { + if err := m.ResourceReferences[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_references" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIPipelineVersion) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIPipelineVersion) UnmarshalBinary(b []byte) error { + var res APIPipelineVersion + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/backend/api/go_http_client/pipeline_upload_model/api_relationship.go b/backend/api/go_http_client/pipeline_upload_model/api_relationship.go new file mode 100644 index 00000000000..402a3471a4c --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_model/api_relationship.go @@ -0,0 +1,80 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/validate" +) + +// APIRelationship api relationship +// swagger:model apiRelationship +type APIRelationship string + +const ( + + // APIRelationshipUNKNOWNRELATIONSHIP captures enum value "UNKNOWN_RELATIONSHIP" + APIRelationshipUNKNOWNRELATIONSHIP APIRelationship = "UNKNOWN_RELATIONSHIP" + + // APIRelationshipOWNER captures enum value "OWNER" + APIRelationshipOWNER APIRelationship = "OWNER" + + // APIRelationshipCREATOR captures enum value "CREATOR" + APIRelationshipCREATOR APIRelationship = "CREATOR" +) + +// for schema +var apiRelationshipEnum []interface{} + +func init() { + var res []APIRelationship + if err := json.Unmarshal([]byte(`["UNKNOWN_RELATIONSHIP","OWNER","CREATOR"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + apiRelationshipEnum = append(apiRelationshipEnum, v) + } +} + +func (m APIRelationship) validateAPIRelationshipEnum(path, location string, value APIRelationship) error { + if err := validate.Enum(path, location, value, apiRelationshipEnum); err != nil { + return err + } + return nil +} + +// Validate validates this api relationship +func (m APIRelationship) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateAPIRelationshipEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/backend/api/go_http_client/pipeline_upload_model/api_resource_key.go b/backend/api/go_http_client/pipeline_upload_model/api_resource_key.go new file mode 100644 index 00000000000..6e57354dfbe --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_model/api_resource_key.go @@ -0,0 +1,86 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// APIResourceKey api resource key +// swagger:model apiResourceKey +type APIResourceKey struct { + + // The ID of the resource that referred to. + ID string `json:"id,omitempty"` + + // The type of the resource that referred to. + Type APIResourceType `json:"type,omitempty"` +} + +// Validate validates this api resource key +func (m *APIResourceKey) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIResourceKey) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + if err := m.Type.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("type") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIResourceKey) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIResourceKey) UnmarshalBinary(b []byte) error { + var res APIResourceKey + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/backend/api/go_http_client/pipeline_upload_model/api_resource_reference.go b/backend/api/go_http_client/pipeline_upload_model/api_resource_reference.go new file mode 100644 index 00000000000..6ea02e865dd --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_model/api_resource_reference.go @@ -0,0 +1,111 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// APIResourceReference api resource reference +// swagger:model apiResourceReference +type APIResourceReference struct { + + // key + Key *APIResourceKey `json:"key,omitempty"` + + // The name of the resource that referred to. + Name string `json:"name,omitempty"` + + // Required field. The relationship from referred resource to the object. + Relationship APIRelationship `json:"relationship,omitempty"` +} + +// Validate validates this api resource reference +func (m *APIResourceReference) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRelationship(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIResourceReference) validateKey(formats strfmt.Registry) error { + + if swag.IsZero(m.Key) { // not required + return nil + } + + if m.Key != nil { + if err := m.Key.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("key") + } + return err + } + } + + return nil +} + +func (m *APIResourceReference) validateRelationship(formats strfmt.Registry) error { + + if swag.IsZero(m.Relationship) { // not required + return nil + } + + if err := m.Relationship.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("relationship") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIResourceReference) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIResourceReference) UnmarshalBinary(b []byte) error { + var res APIResourceReference + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/backend/api/go_http_client/pipeline_upload_model/api_resource_type.go b/backend/api/go_http_client/pipeline_upload_model/api_resource_type.go new file mode 100644 index 00000000000..e068e6ae4ba --- /dev/null +++ b/backend/api/go_http_client/pipeline_upload_model/api_resource_type.go @@ -0,0 +1,89 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by go-swagger; DO NOT EDIT. + +package pipeline_upload_model + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/validate" +) + +// APIResourceType api resource type +// swagger:model apiResourceType +type APIResourceType string + +const ( + + // APIResourceTypeUNKNOWNRESOURCETYPE captures enum value "UNKNOWN_RESOURCE_TYPE" + APIResourceTypeUNKNOWNRESOURCETYPE APIResourceType = "UNKNOWN_RESOURCE_TYPE" + + // APIResourceTypeEXPERIMENT captures enum value "EXPERIMENT" + APIResourceTypeEXPERIMENT APIResourceType = "EXPERIMENT" + + // APIResourceTypeJOB captures enum value "JOB" + APIResourceTypeJOB APIResourceType = "JOB" + + // APIResourceTypePIPELINE captures enum value "PIPELINE" + APIResourceTypePIPELINE APIResourceType = "PIPELINE" + + // APIResourceTypePIPELINEVERSION captures enum value "PIPELINE_VERSION" + APIResourceTypePIPELINEVERSION APIResourceType = "PIPELINE_VERSION" + + // APIResourceTypeNAMESPACE captures enum value "NAMESPACE" + APIResourceTypeNAMESPACE APIResourceType = "NAMESPACE" +) + +// for schema +var apiResourceTypeEnum []interface{} + +func init() { + var res []APIResourceType + if err := json.Unmarshal([]byte(`["UNKNOWN_RESOURCE_TYPE","EXPERIMENT","JOB","PIPELINE","PIPELINE_VERSION","NAMESPACE"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + apiResourceTypeEnum = append(apiResourceTypeEnum, v) + } +} + +func (m APIResourceType) validateAPIResourceTypeEnum(path, location string, value APIResourceType) error { + if err := validate.Enum(path, location, value, apiResourceTypeEnum); err != nil { + return err + } + return nil +} + +// Validate validates this api resource type +func (m APIResourceType) Validate(formats strfmt.Registry) error { + var res []error + + // value enum + if err := m.validateAPIResourceTypeEnum("", "body", m); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +}