// 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_memberships

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

// New creates a new portal memberships 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 memberships 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 memberships 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 {

	// DeleteTenantMembership idempotently soft revoke one membership.
	DeleteTenantMembership(params *DeleteTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteTenantMembershipOK, error)

	// DeleteTenantMembershipContext idempotently soft revoke one membership.
	DeleteTenantMembershipContext(ctx context.Context, params *DeleteTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteTenantMembershipOK, error)

	// GetManageableTenants list tenant contexts the current actor may administer.
	GetManageableTenants(params *GetManageableTenantsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetManageableTenantsOK, error)

	// GetManageableTenantsContext list tenant contexts the current actor may administer.
	GetManageableTenantsContext(ctx context.Context, params *GetManageableTenantsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetManageableTenantsOK, error)

	// GetTenantMembership get one actor visible tenant membership.
	GetTenantMembership(params *GetTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipOK, error)

	// GetTenantMembershipContext get one actor visible tenant membership.
	GetTenantMembershipContext(ctx context.Context, params *GetTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipOK, error)

	// GetTenantMemberships list actor visible tenant memberships.
	GetTenantMemberships(params *GetTenantMembershipsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipsOK, error)

	// GetTenantMembershipsContext list actor visible tenant memberships.
	GetTenantMembershipsContext(ctx context.Context, params *GetTenantMembershipsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipsOK, error)

	// PostTenantMembership create a tenant link or return an exact desired state match.
	PostTenantMembership(params *PostTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostTenantMembershipOK, error)

	// PostTenantMembershipContext create a tenant link or return an exact desired state match.
	PostTenantMembershipContext(ctx context.Context, params *PostTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostTenantMembershipOK, error)

	// PutTenantMembership idempotently change membership access or lifecycle.
	PutTenantMembership(params *PutTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutTenantMembershipOK, error)

	// PutTenantMembershipContext idempotently change membership access or lifecycle.
	PutTenantMembershipContext(ctx context.Context, params *PutTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutTenantMembershipOK, error)

	SetTransport(transport runtime.ContextualTransport)
}

// DeleteTenantMembership idempotentlies soft revoke one membership.
//
// 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.DeleteTenantMembershipContext] instead.
func (a *Client) DeleteTenantMembership(params *DeleteTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteTenantMembershipOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// DeleteTenantMembershipContext idempotentlies soft revoke one membership.
//
// Do not use the deprecated [DeleteTenantMembershipParams.Context] with this method: it would be ignored.
func (a *Client) DeleteTenantMembershipContext(ctx context.Context, params *DeleteTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteTenantMembershipOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewDeleteTenantMembershipParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "deleteTenantMembership",
		Method:             "DELETE",
		PathPattern:        "/tenantmemberships/{membershipId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &DeleteTenantMembershipReader{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.(*DeleteTenantMembershipOK)
	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 deleteTenantMembership: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// GetManageableTenants lists tenant contexts the current actor may administer.
//
// 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.GetManageableTenantsContext] instead.
func (a *Client) GetManageableTenants(params *GetManageableTenantsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetManageableTenantsOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// GetManageableTenantsContext lists tenant contexts the current actor may administer.
//
// Do not use the deprecated [GetManageableTenantsParams.Context] with this method: it would be ignored.
func (a *Client) GetManageableTenantsContext(ctx context.Context, params *GetManageableTenantsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetManageableTenantsOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetManageableTenantsParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getManageableTenants",
		Method:             "GET",
		PathPattern:        "/manageabletenants",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetManageableTenantsReader{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.(*GetManageableTenantsOK)
	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 getManageableTenants: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// GetTenantMembership gets one actor visible tenant membership.
//
// 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.GetTenantMembershipContext] instead.
func (a *Client) GetTenantMembership(params *GetTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// GetTenantMembershipContext gets one actor visible tenant membership.
//
// Do not use the deprecated [GetTenantMembershipParams.Context] with this method: it would be ignored.
func (a *Client) GetTenantMembershipContext(ctx context.Context, params *GetTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetTenantMembershipParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getTenantMembership",
		Method:             "GET",
		PathPattern:        "/tenantmemberships/{membershipId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetTenantMembershipReader{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.(*GetTenantMembershipOK)
	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 getTenantMembership: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// GetTenantMemberships lists actor visible tenant memberships.
//
// 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.GetTenantMembershipsContext] instead.
func (a *Client) GetTenantMemberships(params *GetTenantMembershipsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipsOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// GetTenantMembershipsContext lists actor visible tenant memberships.
//
// Do not use the deprecated [GetTenantMembershipsParams.Context] with this method: it would be ignored.
func (a *Client) GetTenantMembershipsContext(ctx context.Context, params *GetTenantMembershipsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetTenantMembershipsOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetTenantMembershipsParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getTenantMemberships",
		Method:             "GET",
		PathPattern:        "/tenantmemberships",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetTenantMembershipsReader{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.(*GetTenantMembershipsOK)
	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 getTenantMemberships: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PostTenantMembership creates a tenant link or return an exact desired state match.
//
// 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.PostTenantMembershipContext] instead.
func (a *Client) PostTenantMembership(params *PostTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostTenantMembershipOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// PostTenantMembershipContext creates a tenant link or return an exact desired state match.
//
// Do not use the deprecated [PostTenantMembershipParams.Context] with this method: it would be ignored.
func (a *Client) PostTenantMembershipContext(ctx context.Context, params *PostTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostTenantMembershipOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPostTenantMembershipParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "postTenantMembership",
		Method:             "POST",
		PathPattern:        "/tenantmemberships",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PostTenantMembershipReader{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.(*PostTenantMembershipOK)
	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 postTenantMembership: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PutTenantMembership idempotentlies change membership access or lifecycle.
//
// 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.PutTenantMembershipContext] instead.
func (a *Client) PutTenantMembership(params *PutTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutTenantMembershipOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// PutTenantMembershipContext idempotentlies change membership access or lifecycle.
//
// Do not use the deprecated [PutTenantMembershipParams.Context] with this method: it would be ignored.
func (a *Client) PutTenantMembershipContext(ctx context.Context, params *PutTenantMembershipParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutTenantMembershipOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPutTenantMembershipParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "putTenantMembership",
		Method:             "PUT",
		PathPattern:        "/tenantmemberships/{membershipId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PutTenantMembershipReader{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.(*PutTenantMembershipOK)
	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 putTenantMembership: 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 [PortalMembershipsParams].
	ctx context.Context
}
