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

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package portal_clients

import (
	"context"
	"fmt"
	"time"

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

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

// New creates a new portal clients API client with basic auth credentials.
//
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - user: user for basic authentication header.
// - password: password for basic authentication header.
func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService {
	transport := httptransport.New(host, basePath, []string{scheme})
	transport.DefaultAuthentication = httptransport.BasicAuth(user, password)
	return &Client{transport: transport, formats: strfmt.Default}
}

// New creates a new portal clients API client with a bearer token for authentication.
//
// It takes the following parameters:
// - host: http host (github.com).
// - basePath: any base path for the API client ("/v1", "/v3").
// - scheme: http scheme ("http", "https").
// - bearerToken: bearer token for Bearer authentication header.
func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService {
	transport := httptransport.New(host, basePath, []string{scheme})
	transport.DefaultAuthentication = httptransport.BearerToken(bearerToken)
	return &Client{transport: transport, formats: strfmt.Default}
}

// Client for portal clients API.
type Client struct {
	transport runtime.ContextualTransport
	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 {

	// GetAuthorizedClientScopes list approved scopes backed by effective entitlements.
	GetAuthorizedClientScopes(params *GetAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientScopesOK, error)

	// GetAuthorizedClientScopesContext list approved scopes backed by effective entitlements.
	GetAuthorizedClientScopesContext(ctx context.Context, params *GetAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientScopesOK, error)

	// GetAuthorizedClients list non secret authorized client connection metadata.
	GetAuthorizedClients(params *GetAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientsOK, error)

	// GetAuthorizedClientsContext list non secret authorized client connection metadata.
	GetAuthorizedClientsContext(ctx context.Context, params *GetAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientsOK, error)

	// PostAuthorizedClientScopes approve scopes only when backed by effective entitlements.
	PostAuthorizedClientScopes(params *PostAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientScopesOK, error)

	// PostAuthorizedClientScopesContext approve scopes only when backed by effective entitlements.
	PostAuthorizedClientScopesContext(ctx context.Context, params *PostAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientScopesOK, error)

	// PostAuthorizedClients register non secret authorized client metadata.
	PostAuthorizedClients(params *PostAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientsOK, error)

	// PostAuthorizedClientsContext register non secret authorized client metadata.
	PostAuthorizedClientsContext(ctx context.Context, params *PostAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientsOK, error)

	// PutAuthorizedClientScopes update approved client scopes.
	PutAuthorizedClientScopes(params *PutAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientScopesOK, error)

	// PutAuthorizedClientScopesContext update approved client scopes.
	PutAuthorizedClientScopesContext(ctx context.Context, params *PutAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientScopesOK, error)

	// PutAuthorizedClients update or idempotently revoke client metadata.
	PutAuthorizedClients(params *PutAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientsOK, error)

	// PutAuthorizedClientsContext update or idempotently revoke client metadata.
	PutAuthorizedClientsContext(ctx context.Context, params *PutAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientsOK, error)

	SetTransport(transport runtime.ContextualTransport)
}

// GetAuthorizedClientScopes lists approved scopes backed by effective entitlements.
//
// This method does not support injected context.
// However, timeout and opentracing contexts are honored whenever enabled.
//
// If you need to pass a specific context, use [Client.GetAuthorizedClientScopesContext] instead.
func (a *Client) GetAuthorizedClientScopes(params *GetAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientScopesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.GetAuthorizedClientScopesContext(ctx, params, authInfo, opts...)
}

// GetAuthorizedClientScopesContext lists approved scopes backed by effective entitlements.
//
// Do not use the deprecated [GetAuthorizedClientScopesParams.Context] with this method: it would be ignored.
func (a *Client) GetAuthorizedClientScopesContext(ctx context.Context, params *GetAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientScopesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetAuthorizedClientScopesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getAuthorizedClientScopes",
		Method:             "GET",
		PathPattern:        "/authorizedclientscopes",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetAuthorizedClientScopesReader{formats: a.formats},
		AuthInfo:           authInfo,
		Client:             params.HTTPClient,
	}

	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.SubmitContext(ctx, op)
	if err != nil {
		return nil, err
	}

	// only one success response has to be checked
	success, ok := result.(*GetAuthorizedClientScopesOK)
	if ok {
		return success, nil
	}

	// unexpected success response.

	// no default response is defined.
	//
	// safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for getAuthorizedClientScopes: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// GetAuthorizedClients lists non secret authorized client connection metadata.
//
// This method does not support injected context.
// However, timeout and opentracing contexts are honored whenever enabled.
//
// If you need to pass a specific context, use [Client.GetAuthorizedClientsContext] instead.
func (a *Client) GetAuthorizedClients(params *GetAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientsOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.GetAuthorizedClientsContext(ctx, params, authInfo, opts...)
}

// GetAuthorizedClientsContext lists non secret authorized client connection metadata.
//
// Do not use the deprecated [GetAuthorizedClientsParams.Context] with this method: it would be ignored.
func (a *Client) GetAuthorizedClientsContext(ctx context.Context, params *GetAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAuthorizedClientsOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetAuthorizedClientsParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getAuthorizedClients",
		Method:             "GET",
		PathPattern:        "/authorizedclients",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetAuthorizedClientsReader{formats: a.formats},
		AuthInfo:           authInfo,
		Client:             params.HTTPClient,
	}

	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.SubmitContext(ctx, op)
	if err != nil {
		return nil, err
	}

	// only one success response has to be checked
	success, ok := result.(*GetAuthorizedClientsOK)
	if ok {
		return success, nil
	}

	// unexpected success response.

	// no default response is defined.
	//
	// safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for getAuthorizedClients: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PostAuthorizedClientScopes approves scopes only when backed by effective entitlements.
//
// This method does not support injected context.
// However, timeout and opentracing contexts are honored whenever enabled.
//
// If you need to pass a specific context, use [Client.PostAuthorizedClientScopesContext] instead.
func (a *Client) PostAuthorizedClientScopes(params *PostAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientScopesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.PostAuthorizedClientScopesContext(ctx, params, authInfo, opts...)
}

// PostAuthorizedClientScopesContext approves scopes only when backed by effective entitlements.
//
// Do not use the deprecated [PostAuthorizedClientScopesParams.Context] with this method: it would be ignored.
func (a *Client) PostAuthorizedClientScopesContext(ctx context.Context, params *PostAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientScopesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPostAuthorizedClientScopesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "postAuthorizedClientScopes",
		Method:             "POST",
		PathPattern:        "/authorizedclientscopes",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PostAuthorizedClientScopesReader{formats: a.formats},
		AuthInfo:           authInfo,
		Client:             params.HTTPClient,
	}

	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.SubmitContext(ctx, op)
	if err != nil {
		return nil, err
	}

	// only one success response has to be checked
	success, ok := result.(*PostAuthorizedClientScopesOK)
	if ok {
		return success, nil
	}

	// unexpected success response.

	// no default response is defined.
	//
	// safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for postAuthorizedClientScopes: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PostAuthorizedClients registers non secret authorized client metadata.
//
// This method does not support injected context.
// However, timeout and opentracing contexts are honored whenever enabled.
//
// If you need to pass a specific context, use [Client.PostAuthorizedClientsContext] instead.
func (a *Client) PostAuthorizedClients(params *PostAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientsOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.PostAuthorizedClientsContext(ctx, params, authInfo, opts...)
}

// PostAuthorizedClientsContext registers non secret authorized client metadata.
//
// Do not use the deprecated [PostAuthorizedClientsParams.Context] with this method: it would be ignored.
func (a *Client) PostAuthorizedClientsContext(ctx context.Context, params *PostAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostAuthorizedClientsOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPostAuthorizedClientsParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "postAuthorizedClients",
		Method:             "POST",
		PathPattern:        "/authorizedclients",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PostAuthorizedClientsReader{formats: a.formats},
		AuthInfo:           authInfo,
		Client:             params.HTTPClient,
	}

	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.SubmitContext(ctx, op)
	if err != nil {
		return nil, err
	}

	// only one success response has to be checked
	success, ok := result.(*PostAuthorizedClientsOK)
	if ok {
		return success, nil
	}

	// unexpected success response.

	// no default response is defined.
	//
	// safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for postAuthorizedClients: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PutAuthorizedClientScopes updates approved client scopes.
//
// This method does not support injected context.
// However, timeout and opentracing contexts are honored whenever enabled.
//
// If you need to pass a specific context, use [Client.PutAuthorizedClientScopesContext] instead.
func (a *Client) PutAuthorizedClientScopes(params *PutAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientScopesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.PutAuthorizedClientScopesContext(ctx, params, authInfo, opts...)
}

// PutAuthorizedClientScopesContext updates approved client scopes.
//
// Do not use the deprecated [PutAuthorizedClientScopesParams.Context] with this method: it would be ignored.
func (a *Client) PutAuthorizedClientScopesContext(ctx context.Context, params *PutAuthorizedClientScopesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientScopesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPutAuthorizedClientScopesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "putAuthorizedClientScopes",
		Method:             "PUT",
		PathPattern:        "/authorizedclientscopes",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PutAuthorizedClientScopesReader{formats: a.formats},
		AuthInfo:           authInfo,
		Client:             params.HTTPClient,
	}

	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.SubmitContext(ctx, op)
	if err != nil {
		return nil, err
	}

	// only one success response has to be checked
	success, ok := result.(*PutAuthorizedClientScopesOK)
	if ok {
		return success, nil
	}

	// unexpected success response.

	// no default response is defined.
	//
	// safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for putAuthorizedClientScopes: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PutAuthorizedClients updates or idempotently revoke client metadata.
//
// This method does not support injected context.
// However, timeout and opentracing contexts are honored whenever enabled.
//
// If you need to pass a specific context, use [Client.PutAuthorizedClientsContext] instead.
func (a *Client) PutAuthorizedClients(params *PutAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientsOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.PutAuthorizedClientsContext(ctx, params, authInfo, opts...)
}

// PutAuthorizedClientsContext updates or idempotently revoke client metadata.
//
// Do not use the deprecated [PutAuthorizedClientsParams.Context] with this method: it would be ignored.
func (a *Client) PutAuthorizedClientsContext(ctx context.Context, params *PutAuthorizedClientsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutAuthorizedClientsOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPutAuthorizedClientsParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "putAuthorizedClients",
		Method:             "PUT",
		PathPattern:        "/authorizedclients",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PutAuthorizedClientsReader{formats: a.formats},
		AuthInfo:           authInfo,
		Client:             params.HTTPClient,
	}

	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.SubmitContext(ctx, op)
	if err != nil {
		return nil, err
	}

	// only one success response has to be checked
	success, ok := result.(*PutAuthorizedClientsOK)
	if ok {
		return success, nil
	}

	// unexpected success response.

	// no default response is defined.
	//
	// safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for putAuthorizedClients: 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.ContextualTransport) {
	a.transport = transport
}

// innerParams captures internal fields so they don't conflict with user-supplied parameters.
type innerParams struct {
	timeout time.Duration

	// Deprecated: use the operation call with context to pass the context instead of [PortalClientsParams].
	ctx context.Context
}
