1 Star 1 Fork 0

FlexLB/flexlb-client-go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
instance_client.go 10.01 KB
一键复制 编辑 原始数据 按行查看 历史
王耀辉 提交于 2022-04-21 19:13 +08:00 . 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 (
"fmt"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// New creates a new instance API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
/*
Client for instance API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption is the option for Client methods
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
Create(params *CreateParams, opts ...ClientOption) (*CreateOK, error)
Delete(params *DeleteParams, opts ...ClientOption) (*DeleteOK, error)
Get(params *GetParams, opts ...ClientOption) (*GetOK, error)
List(params *ListParams, opts ...ClientOption) (*ListOK, error)
Modify(params *ModifyParams, opts ...ClientOption) (*ModifyOK, error)
Start(params *StartParams, opts ...ClientOption) (*StartOK, error)
Stop(params *StopParams, opts ...ClientOption) (*StopOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
Create Create Instance
*/
func (a *Client) Create(params *CreateParams, opts ...ClientOption) (*CreateOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateParams()
}
op := &runtime.ClientOperation{
ID: "create",
Method: "POST",
PathPattern: "/instances",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &CreateReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for create: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Delete Delete Instance
*/
func (a *Client) Delete(params *DeleteParams, opts ...ClientOption) (*DeleteOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteParams()
}
op := &runtime.ClientOperation{
ID: "delete",
Method: "DELETE",
PathPattern: "/instances/{name}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &DeleteReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*DeleteOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for delete: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Get Get Instance
*/
func (a *Client) Get(params *GetParams, opts ...ClientOption) (*GetOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetParams()
}
op := &runtime.ClientOperation{
ID: "get",
Method: "GET",
PathPattern: "/instances/{name}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &GetReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for get: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
List List Instances
*/
func (a *Client) List(params *ListParams, opts ...ClientOption) (*ListOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListParams()
}
op := &runtime.ClientOperation{
ID: "list",
Method: "GET",
PathPattern: "/instances",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &ListReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for list: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Modify Modify Instance
*/
func (a *Client) Modify(params *ModifyParams, opts ...ClientOption) (*ModifyOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewModifyParams()
}
op := &runtime.ClientOperation{
ID: "modify",
Method: "PUT",
PathPattern: "/instances",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &ModifyReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ModifyOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for modify: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Start Start instance
*/
func (a *Client) Start(params *StartParams, opts ...ClientOption) (*StartOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewStartParams()
}
op := &runtime.ClientOperation{
ID: "start",
Method: "POST",
PathPattern: "/instances/{name}/start",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &StartReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*StartOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for start: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Stop Stop Instance
*/
func (a *Client) Stop(params *StopParams, opts ...ClientOption) (*StopOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewStopParams()
}
op := &runtime.ClientOperation{
ID: "stop",
Method: "POST",
PathPattern: "/instances/{name}/stop",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &StopReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*StopOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for stop: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
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

搜索帮助