1 Star 1 Fork 0

FlexLB / flexlb-client-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
get_responses.go 11.20 KB
一键复制 编辑 原始数据 按行查看 历史
王耀辉 提交于 2022-04-21 11:13 . add license
// Copyright (c) 2022 Yaohui Wang (yaohuiwang@outlook.com)
// FlexLB is licensed under Mulan PubL v2.
// You can use this software according to the terms and conditions of the Mulan PubL v2.
// You may obtain a copy of Mulan PubL v2 at:
// http://license.coscl.org.cn/MulanPubL-2.0
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PubL v2 for more details.
// Code generated by go-swagger; DO NOT EDIT.
package instance
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"fmt"
"io"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
"gitee.com/flexlb/flexlb-client-go/models"
)
// GetReader is a Reader for the Get structure.
type GetReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewGetBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 401:
result := NewGetUnauthorized()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 403:
result := NewGetForbidden()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 404:
result := NewGetNotFound()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 500:
result := NewGetInternalServerError()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
}
}
// NewGetOK creates a GetOK with default headers values
func NewGetOK() *GetOK {
return &GetOK{}
}
/* GetOK describes a response with status code 200, with default header values.
Get Instance succeeded
*/
type GetOK struct {
Payload *models.Instance
}
func (o *GetOK) Error() string {
return fmt.Sprintf("[GET /instances/{name}][%d] getOK %+v", 200, o.Payload)
}
func (o *GetOK) GetPayload() *models.Instance {
return o.Payload
}
func (o *GetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Instance)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetBadRequest creates a GetBadRequest with default headers values
func NewGetBadRequest() *GetBadRequest {
return &GetBadRequest{}
}
/* GetBadRequest describes a response with status code 400, with default header values.
GetBadRequest get bad request
*/
type GetBadRequest struct {
Payload *GetBadRequestBody
}
func (o *GetBadRequest) Error() string {
return fmt.Sprintf("[GET /instances/{name}][%d] getBadRequest %+v", 400, o.Payload)
}
func (o *GetBadRequest) GetPayload() *GetBadRequestBody {
return o.Payload
}
func (o *GetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(GetBadRequestBody)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetUnauthorized creates a GetUnauthorized with default headers values
func NewGetUnauthorized() *GetUnauthorized {
return &GetUnauthorized{}
}
/* GetUnauthorized describes a response with status code 401, with default header values.
GetUnauthorized get unauthorized
*/
type GetUnauthorized struct {
Payload interface{}
}
func (o *GetUnauthorized) Error() string {
return fmt.Sprintf("[GET /instances/{name}][%d] getUnauthorized %+v", 401, o.Payload)
}
func (o *GetUnauthorized) GetPayload() interface{} {
return o.Payload
}
func (o *GetUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetForbidden creates a GetForbidden with default headers values
func NewGetForbidden() *GetForbidden {
return &GetForbidden{}
}
/* GetForbidden describes a response with status code 403, with default header values.
GetForbidden get forbidden
*/
type GetForbidden struct {
Payload *GetForbiddenBody
}
func (o *GetForbidden) Error() string {
return fmt.Sprintf("[GET /instances/{name}][%d] getForbidden %+v", 403, o.Payload)
}
func (o *GetForbidden) GetPayload() *GetForbiddenBody {
return o.Payload
}
func (o *GetForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(GetForbiddenBody)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetNotFound creates a GetNotFound with default headers values
func NewGetNotFound() *GetNotFound {
return &GetNotFound{}
}
/* GetNotFound describes a response with status code 404, with default header values.
GetNotFound get not found
*/
type GetNotFound struct {
Payload *GetNotFoundBody
}
func (o *GetNotFound) Error() string {
return fmt.Sprintf("[GET /instances/{name}][%d] getNotFound %+v", 404, o.Payload)
}
func (o *GetNotFound) GetPayload() *GetNotFoundBody {
return o.Payload
}
func (o *GetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(GetNotFoundBody)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetInternalServerError creates a GetInternalServerError with default headers values
func NewGetInternalServerError() *GetInternalServerError {
return &GetInternalServerError{}
}
/* GetInternalServerError describes a response with status code 500, with default header values.
GetInternalServerError get internal server error
*/
type GetInternalServerError struct {
Payload interface{}
}
func (o *GetInternalServerError) Error() string {
return fmt.Sprintf("[GET /instances/{name}][%d] getInternalServerError %+v", 500, o.Payload)
}
func (o *GetInternalServerError) GetPayload() interface{} {
return o.Payload
}
func (o *GetInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
/*GetBadRequestBody get bad request body
swagger:model GetBadRequestBody
*/
type GetBadRequestBody struct {
// message
// Required: true
Message *string `json:"message"`
}
// Validate validates this get bad request body
func (o *GetBadRequestBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateMessage(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetBadRequestBody) validateMessage(formats strfmt.Registry) error {
if err := validate.Required("getBadRequest"+"."+"message", "body", o.Message); err != nil {
return err
}
return nil
}
// ContextValidate validates this get bad request body based on context it is used
func (o *GetBadRequestBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *GetBadRequestBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *GetBadRequestBody) UnmarshalBinary(b []byte) error {
var res GetBadRequestBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}
/*GetForbiddenBody get forbidden body
swagger:model GetForbiddenBody
*/
type GetForbiddenBody struct {
// message
// Required: true
Message *string `json:"message"`
}
// Validate validates this get forbidden body
func (o *GetForbiddenBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateMessage(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetForbiddenBody) validateMessage(formats strfmt.Registry) error {
if err := validate.Required("getForbidden"+"."+"message", "body", o.Message); err != nil {
return err
}
return nil
}
// ContextValidate validates this get forbidden body based on context it is used
func (o *GetForbiddenBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *GetForbiddenBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *GetForbiddenBody) UnmarshalBinary(b []byte) error {
var res GetForbiddenBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}
/*GetNotFoundBody get not found body
swagger:model GetNotFoundBody
*/
type GetNotFoundBody struct {
// error
// Required: true
Error *string `json:"error"`
// status
// Required: true
Status *string `json:"status"`
}
// Validate validates this get not found body
func (o *GetNotFoundBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateError(formats); err != nil {
res = append(res, err)
}
if err := o.validateStatus(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *GetNotFoundBody) validateError(formats strfmt.Registry) error {
if err := validate.Required("getNotFound"+"."+"error", "body", o.Error); err != nil {
return err
}
return nil
}
func (o *GetNotFoundBody) validateStatus(formats strfmt.Registry) error {
if err := validate.Required("getNotFound"+"."+"status", "body", o.Status); err != nil {
return err
}
return nil
}
// ContextValidate validates this get not found body based on context it is used
func (o *GetNotFoundBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *GetNotFoundBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *GetNotFoundBody) UnmarshalBinary(b []byte) error {
var res GetNotFoundBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}
Go
1
https://gitee.com/flexlb/flexlb-client-go.git
git@gitee.com:flexlb/flexlb-client-go.git
flexlb
flexlb-client-go
flexlb-client-go
v0.4.2

搜索帮助