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

package auth

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

/*
Client for auth API
*/
type Client struct {
	transport runtime.ClientTransport
	formats   strfmt.Registry
}

// ClientOption may be used to customize the behavior of Client methods.
type ClientOption func(*runtime.ClientOperation)

// ClientService is the interface for Client methods
type ClientService interface {
	AppInfo(params *AppInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AppInfoOK, error)

	ApproveToken(params *ApproveTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ApproveTokenOK, error)

	Authorize(params *AuthorizeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AuthorizeOK, error)

	ExtAuthz(params *ExtAuthzParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ExtAuthzOK, error)

	RequestToken(params *RequestTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RequestTokenOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
AppInfo gets app info
*/
func (a *Client) AppInfo(params *AppInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AppInfoOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewAppInfoParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "AppInfo",
		Method:             "GET",
		PathPattern:        "/v1alpha1/auth/app_info",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &AppInfoReader{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.(*AppInfoOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*AppInfoDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
ApproveToken handles manual approval of external authorization requets
*/
func (a *Client) ApproveToken(params *ApproveTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ApproveTokenOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewApproveTokenParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "ApproveToken",
		Method:             "POST",
		PathPattern:        "/v1alpha1/auth/approve_token",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &ApproveTokenReader{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.(*ApproveTokenOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*ApproveTokenDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
Authorize authorizes a request from an agent or m c p server
*/
func (a *Client) Authorize(params *AuthorizeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AuthorizeOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewAuthorizeParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "Authorize",
		Method:             "POST",
		PathPattern:        "/v1alpha1/auth/authorize",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &AuthorizeReader{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.(*AuthorizeOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*AuthorizeDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
ExtAuthz handles external authorization requests
*/
func (a *Client) ExtAuthz(params *ExtAuthzParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ExtAuthzOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewExtAuthzParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "ExtAuthz",
		Method:             "POST",
		PathPattern:        "/v1alpha1/auth/ext_authz",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &ExtAuthzReader{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.(*ExtAuthzOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*ExtAuthzDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
RequestToken requests token for an agent or m c p server
*/
func (a *Client) RequestToken(params *RequestTokenParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RequestTokenOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewRequestTokenParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "RequestToken",
		Method:             "POST",
		PathPattern:        "/v1alpha1/auth/token",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &RequestTokenReader{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.(*RequestTokenOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*RequestTokenDefault)
	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
}
