// Code generated by go-swagger; DO NOT EDIT.

package routing_rules

// 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 routing rules API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
	return &Client{transport: transport, formats: formats}
}

/*
Client for routing rules 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 {
	CreateRoutingRule(params *CreateRoutingRuleParams, opts ...ClientOption) (*CreateRoutingRuleNoContent, error)

	DeleteRoutingRule(params *DeleteRoutingRuleParams, opts ...ClientOption) (*DeleteRoutingRuleNoContent, error)

	GetRoutingRule(params *GetRoutingRuleParams, opts ...ClientOption) (*GetRoutingRuleOK, error)

	GetRoutingRules(params *GetRoutingRulesParams, opts ...ClientOption) (*GetRoutingRulesOK, error)

	UpdateRoutingRule(params *UpdateRoutingRuleParams, opts ...ClientOption) (*UpdateRoutingRuleNoContent, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
CreateRoutingRule creates a single routing rule
*/
func (a *Client) CreateRoutingRule(params *CreateRoutingRuleParams, opts ...ClientOption) (*CreateRoutingRuleNoContent, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewCreateRoutingRuleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "createRoutingRule",
		Method:             "POST",
		PathPattern:        "/v1/routing-rules",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &CreateRoutingRuleReader{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.(*CreateRoutingRuleNoContent)
	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 createRoutingRule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
DeleteRoutingRule deletes a single routing rule
*/
func (a *Client) DeleteRoutingRule(params *DeleteRoutingRuleParams, opts ...ClientOption) (*DeleteRoutingRuleNoContent, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteRoutingRuleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "deleteRoutingRule",
		Method:             "DELETE",
		PathPattern:        "/v1/routing-rules/{name}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &DeleteRoutingRuleReader{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.(*DeleteRoutingRuleNoContent)
	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 deleteRoutingRule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
GetRoutingRule gets a single routing rule
*/
func (a *Client) GetRoutingRule(params *GetRoutingRuleParams, opts ...ClientOption) (*GetRoutingRuleOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetRoutingRuleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getRoutingRule",
		Method:             "GET",
		PathPattern:        "/v1/routing-rules/{name}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetRoutingRuleReader{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.(*GetRoutingRuleOK)
	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 getRoutingRule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
GetRoutingRules lists routing rules
*/
func (a *Client) GetRoutingRules(params *GetRoutingRulesParams, opts ...ClientOption) (*GetRoutingRulesOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetRoutingRulesParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getRoutingRules",
		Method:             "GET",
		PathPattern:        "/v1/routing-rules",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetRoutingRulesReader{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.(*GetRoutingRulesOK)
	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 getRoutingRules: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
UpdateRoutingRule updates a single routing rule
*/
func (a *Client) UpdateRoutingRule(params *UpdateRoutingRuleParams, opts ...ClientOption) (*UpdateRoutingRuleNoContent, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewUpdateRoutingRuleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "updateRoutingRule",
		Method:             "PUT",
		PathPattern:        "/v1/routing-rules/{name}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &UpdateRoutingRuleReader{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.(*UpdateRoutingRuleNoContent)
	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 updateRoutingRule: 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
}
