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

package settings

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

/*
Client for settings 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 {
	GetSettings(params *GetSettingsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetSettingsOK, error)

	SetUpIssuer(params *SetUpIssuerParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SetUpIssuerOK, error)

	SettingsServiceSetAPIKey(params *SettingsServiceSetAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SettingsServiceSetAPIKeyOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
GetSettings gets settings for the tenant
*/
func (a *Client) GetSettings(params *GetSettingsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetSettingsOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetSettingsParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "Get Settings",
		Method:             "GET",
		PathPattern:        "/v1alpha1/settings",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetSettingsReader{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.(*GetSettingsOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetSettingsDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
SetUpIssuer creates and register issuer for the tenant revoke any previous issuer
*/
func (a *Client) SetUpIssuer(params *SetUpIssuerParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SetUpIssuerOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewSetUpIssuerParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "Set up Issuer",
		Method:             "POST",
		PathPattern:        "/v1alpha1/settings/issuer",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &SetUpIssuerReader{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.(*SetUpIssuerOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*SetUpIssuerDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
SettingsServiceSetAPIKey sets up API key

Create a new API Key for the Tenant. Revoke any previous API Key
*/
func (a *Client) SettingsServiceSetAPIKey(params *SettingsServiceSetAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SettingsServiceSetAPIKeyOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewSettingsServiceSetAPIKeyParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "SettingsService_SetApiKey",
		Method:             "POST",
		PathPattern:        "/v1alpha1/settings/api-key",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &SettingsServiceSetAPIKeyReader{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.(*SettingsServiceSetAPIKeyOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*SettingsServiceSetAPIKeyDefault)
	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
}
