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

package nodes

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

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

// New creates a new nodes API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
	return &Client{transport: transport, formats: formats}
}

/*
Client for nodes 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 {
	GetNode(params *GetNodeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetNodeOK, error)

	ListClusterNodes(params *ListClusterNodesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListClusterNodesOK, error)

	ListNodes(params *ListNodesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListNodesOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
GetNode get node API
*/
func (a *Client) GetNode(params *GetNodeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetNodeOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetNodeParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "Get Node",
		Method:             "GET",
		PathPattern:        "/2023-10-10/{parent_resource_name}/node/{node_name}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetNodeReader{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.(*GetNodeOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetNodeDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
ListClusterNodes list cluster nodes API
*/
func (a *Client) ListClusterNodes(params *ListClusterNodesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListClusterNodesOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewListClusterNodesParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "List Cluster Nodes",
		Method:             "GET",
		PathPattern:        "/2023-10-10/{parent_resource_name}/nodes",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &ListClusterNodesReader{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.(*ListClusterNodesOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*ListClusterNodesDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
ListNodes nodes API
*/
func (a *Client) ListNodes(params *ListNodesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListNodesOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewListNodesParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "List Nodes",
		Method:             "GET",
		PathPattern:        "/2023-10-10/consul/{project_resource_name}/nodes",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &ListNodesReader{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.(*ListNodesOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*ListNodesDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
	a.transport = transport
}
