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

package identities

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"fmt"

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

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

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

// ClientService is the interface for Client methods
type ClientService interface {
	AddIdentity(params *AddIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*AddIdentityOK, error)

	DeleteIdentity(params *DeleteIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteIdentityOK, error)

	EditIdentity(params *EditIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*EditIdentityOK, error)

	GetIdentity(params *GetIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*GetIdentityOK, error)

	ListIdentities(params *ListIdentitiesParams, authInfo runtime.ClientAuthInfoWriter) (*ListIdentitiesOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
  AddIdentity creates a new identity

  Create a new identity
*/
func (a *Client) AddIdentity(params *AddIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*AddIdentityOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewAddIdentityParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "addIdentity",
		Method:             "POST",
		PathPattern:        "/identities",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &AddIdentityReader{formats: a.formats},
		AuthInfo:           authInfo,
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	success, ok := result.(*AddIdentityOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for addIdentity: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  DeleteIdentity deletes an identity

  Delete an identity
*/
func (a *Client) DeleteIdentity(params *DeleteIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteIdentityOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteIdentityParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "deleteIdentity",
		Method:             "DELETE",
		PathPattern:        "/identities/{identityID}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &DeleteIdentityReader{formats: a.formats},
		AuthInfo:           authInfo,
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	success, ok := result.(*DeleteIdentityOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for deleteIdentity: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  EditIdentity edits an identity

  Edit an identity
*/
func (a *Client) EditIdentity(params *EditIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*EditIdentityOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewEditIdentityParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "editIdentity",
		Method:             "POST",
		PathPattern:        "/identities/{identityID}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &EditIdentityReader{formats: a.formats},
		AuthInfo:           authInfo,
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	success, ok := result.(*EditIdentityOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for editIdentity: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  GetIdentity retrieves an identity

  Return a specific identity matching identityID
*/
func (a *Client) GetIdentity(params *GetIdentityParams, authInfo runtime.ClientAuthInfoWriter) (*GetIdentityOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetIdentityParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "getIdentity",
		Method:             "GET",
		PathPattern:        "/identities/{identityID}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetIdentityReader{formats: a.formats},
		AuthInfo:           authInfo,
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	success, ok := result.(*GetIdentityOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for getIdentity: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
  ListIdentities lists of visible identities

  Retrieve all identities from the system that the user has access to
*/
func (a *Client) ListIdentities(params *ListIdentitiesParams, authInfo runtime.ClientAuthInfoWriter) (*ListIdentitiesOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewListIdentitiesParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "listIdentities",
		Method:             "GET",
		PathPattern:        "/identities",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &ListIdentitiesReader{formats: a.formats},
		AuthInfo:           authInfo,
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	success, ok := result.(*ListIdentitiesOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for listIdentities: 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.ClientTransport) {
	a.transport = transport
}
