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

package app

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

/*
Client for app 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 {
	CreateApp(params *CreateAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateAppOK, error)

	CreateOasfApp(params *CreateOasfAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOasfAppOK, error)

	DeleteApp(params *DeleteAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteAppOK, error)

	GetApp(params *GetAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAppOK, error)

	GetAppBadge(params *GetAppBadgeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAppBadgeOK, error)

	GetAppsCount(params *GetAppsCountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAppsCountOK, error)

	GetTasks(params *GetTasksParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTasksOK, error)

	ListApps(params *ListAppsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListAppsOK, error)

	RefreshAppAPIKey(params *RefreshAppAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RefreshAppAPIKeyOK, error)

	UpdateApp(params *UpdateAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateAppOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
CreateApp creates app
*/
func (a *Client) CreateApp(params *CreateAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateAppOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewCreateAppParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "CreateApp",
		Method:             "POST",
		PathPattern:        "/v1alpha1/apps",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &CreateAppReader{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.(*CreateAppOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*CreateAppDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
CreateOasfApp creates an o a s f app from an o a s f schema and issue a badge
*/
func (a *Client) CreateOasfApp(params *CreateOasfAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateOasfAppOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewCreateOasfAppParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "CreateOasfApp",
		Method:             "POST",
		PathPattern:        "/v1alpha1/apps/oasf",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &CreateOasfAppReader{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.(*CreateOasfAppOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*CreateOasfAppDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
DeleteApp deletes app
*/
func (a *Client) DeleteApp(params *DeleteAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteAppOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteAppParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "DeleteApp",
		Method:             "DELETE",
		PathPattern:        "/v1alpha1/apps/{appId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &DeleteAppReader{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.(*DeleteAppOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*DeleteAppDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
GetApp gets app by Id
*/
func (a *Client) GetApp(params *GetAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAppOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetAppParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "GetApp",
		Method:             "GET",
		PathPattern:        "/v1alpha1/apps/{appId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetAppReader{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.(*GetAppOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetAppDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
GetAppBadge gets the current badge issued for the app using the app ID or the resolver metadata ID
*/
func (a *Client) GetAppBadge(params *GetAppBadgeParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAppBadgeOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetAppBadgeParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "GetAppBadge",
		Method:             "GET",
		PathPattern:        "/v1alpha1/apps/{appId}/badge",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetAppBadgeReader{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.(*GetAppBadgeOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetAppBadgeDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
GetAppsCount gets apps count per type
*/
func (a *Client) GetAppsCount(params *GetAppsCountParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAppsCountOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetAppsCountParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "GetAppsCount",
		Method:             "GET",
		PathPattern:        "/v1alpha1/apps/all/count",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetAppsCountReader{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.(*GetAppsCountOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetAppsCountDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
GetTasks gets the list of tasks of all apps
*/
func (a *Client) GetTasks(params *GetTasksParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTasksOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetTasksParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "GetTasks",
		Method:             "GET",
		PathPattern:        "/v1alpha1/tasks",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetTasksReader{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.(*GetTasksOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetTasksDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
ListApps lists apps
*/
func (a *Client) ListApps(params *ListAppsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListAppsOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewListAppsParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "ListApps",
		Method:             "GET",
		PathPattern:        "/v1alpha1/apps",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &ListAppsReader{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.(*ListAppsOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*ListAppsDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
RefreshAppAPIKey refreshes the API key for an app
*/
func (a *Client) RefreshAppAPIKey(params *RefreshAppAPIKeyParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RefreshAppAPIKeyOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewRefreshAppAPIKeyParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "RefreshAppApiKey",
		Method:             "GET",
		PathPattern:        "/v1alpha1/apps/{appId}/api-key/refresh",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &RefreshAppAPIKeyReader{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.(*RefreshAppAPIKeyOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*RefreshAppAPIKeyDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
UpdateApp updates app
*/
func (a *Client) UpdateApp(params *UpdateAppParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateAppOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewUpdateAppParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "UpdateApp",
		Method:             "PATCH",
		PathPattern:        "/v1alpha1/apps/{appId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &UpdateAppReader{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.(*UpdateAppOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*UpdateAppDefault)
	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
}
