package gc

import (
	"fmt"

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
)

func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
	return &Client{transport: transport, formats: formats}
}

type Client struct {
	transport runtime.ClientTransport
	formats   strfmt.Registry
}

type ClientOption func(*runtime.ClientOperation)

type ClientService interface {
	CreateGCSchedule(params *CreateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGCScheduleCreated, error)

	GetGC(params *GetGCParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCOK, error)

	GetGCHistory(params *GetGCHistoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCHistoryOK, error)

	GetGCLog(params *GetGCLogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCLogOK, error)

	GetGCSchedule(params *GetGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCScheduleOK, error)

	UpdateGCSchedule(params *UpdateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGCScheduleOK, error)

	SetTransport(transport runtime.ClientTransport)
}

func (a *Client) CreateGCSchedule(params *CreateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGCScheduleCreated, error) {

	if params == nil {
		params = NewCreateGCScheduleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "createGCSchedule",
		Method:             "POST",
		PathPattern:        "/system/gc/schedule",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &CreateGCScheduleReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*CreateGCScheduleCreated)
	if ok {
		return success, nil
	}

	msg := fmt.Sprintf("unexpected success response for createGCSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

func (a *Client) GetGC(params *GetGCParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCOK, error) {

	if params == nil {
		params = NewGetGCParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGC",
		Method:             "GET",
		PathPattern:        "/system/gc/{gc_id}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCOK)
	if ok {
		return success, nil
	}

	msg := fmt.Sprintf("unexpected success response for getGC: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

func (a *Client) GetGCHistory(params *GetGCHistoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCHistoryOK, error) {

	if params == nil {
		params = NewGetGCHistoryParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGCHistory",
		Method:             "GET",
		PathPattern:        "/system/gc",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCHistoryReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCHistoryOK)
	if ok {
		return success, nil
	}

	msg := fmt.Sprintf("unexpected success response for getGCHistory: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

func (a *Client) GetGCLog(params *GetGCLogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCLogOK, error) {

	if params == nil {
		params = NewGetGCLogParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGCLog",
		Method:             "GET",
		PathPattern:        "/system/gc/{gc_id}/log",
		ProducesMediaTypes: []string{"text/plain"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCLogReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCLogOK)
	if ok {
		return success, nil
	}

	msg := fmt.Sprintf("unexpected success response for getGCLog: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

func (a *Client) GetGCSchedule(params *GetGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCScheduleOK, error) {

	if params == nil {
		params = NewGetGCScheduleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGCSchedule",
		Method:             "GET",
		PathPattern:        "/system/gc/schedule",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCScheduleReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCScheduleOK)
	if ok {
		return success, nil
	}

	msg := fmt.Sprintf("unexpected success response for getGCSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

func (a *Client) UpdateGCSchedule(params *UpdateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGCScheduleOK, error) {

	if params == nil {
		params = NewUpdateGCScheduleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "updateGCSchedule",
		Method:             "PUT",
		PathPattern:        "/system/gc/schedule",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &UpdateGCScheduleReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*UpdateGCScheduleOK)
	if ok {
		return success, nil
	}

	msg := fmt.Sprintf("unexpected success response for updateGCSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

func (a *Client) SetTransport(transport runtime.ClientTransport) {
	a.transport = transport
}
// Code generated by go-swagger; DO NOT EDIT.

package gc

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

/*
Client for gc 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 {
	CreateGCSchedule(params *CreateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGCScheduleCreated, error)

	GetGC(params *GetGCParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCOK, error)

	GetGCHistory(params *GetGCHistoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCHistoryOK, error)

	GetGCLog(params *GetGCLogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCLogOK, error)

	GetGCSchedule(params *GetGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCScheduleOK, error)

	UpdateGCSchedule(params *UpdateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGCScheduleOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
  CreateGCSchedule creates a gc schedule

  This endpoint is for update gc schedule.

*/
func (a *Client) CreateGCSchedule(params *CreateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateGCScheduleCreated, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewCreateGCScheduleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "createGCSchedule",
		Method:             "POST",
		PathPattern:        "/system/gc/schedule",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &CreateGCScheduleReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*CreateGCScheduleCreated)
	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 createGCSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  GetGC gets gc status

  This endpoint let user get gc status filtered by specific ID.
*/
func (a *Client) GetGC(params *GetGCParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetGCParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGC",
		Method:             "GET",
		PathPattern:        "/system/gc/{gc_id}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCOK)
	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 getGC: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  GetGCHistory gets gc results

  This endpoint let user get gc execution history.
*/
func (a *Client) GetGCHistory(params *GetGCHistoryParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCHistoryOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetGCHistoryParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGCHistory",
		Method:             "GET",
		PathPattern:        "/system/gc",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCHistoryReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCHistoryOK)
	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 getGCHistory: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  GetGCLog gets gc job log

  This endpoint let user get gc job logs filtered by specific ID.
*/
func (a *Client) GetGCLog(params *GetGCLogParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCLogOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetGCLogParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGCLog",
		Method:             "GET",
		PathPattern:        "/system/gc/{gc_id}/log",
		ProducesMediaTypes: []string{"text/plain"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCLogReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCLogOK)
	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 getGCLog: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  GetGCSchedule gets gc s schedule

  This endpoint is for get schedule of gc job.
*/
func (a *Client) GetGCSchedule(params *GetGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetGCScheduleOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetGCScheduleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "getGCSchedule",
		Method:             "GET",
		PathPattern:        "/system/gc/schedule",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetGCScheduleReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*GetGCScheduleOK)
	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 getGCSchedule: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  UpdateGCSchedule updates gc s schedule

  This endpoint is for update gc schedule.

*/
func (a *Client) UpdateGCSchedule(params *UpdateGCScheduleParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateGCScheduleOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewUpdateGCScheduleParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "updateGCSchedule",
		Method:             "PUT",
		PathPattern:        "/system/gc/schedule",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &UpdateGCScheduleReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*UpdateGCScheduleOK)
	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 updateGCSchedule: 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
}
