participants

package
v0.0.0-...-e76cf3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TYPE_BOTH    = "BOTH"
	TYPE_ISSUED  = "ISSUED"
	TYPE_TRUSTED = "TRUSTED"
)
View Source
var LOGGER = logging.MustGetLogger("participants")

Functions

This section is empty.

Types

type ParticipantOperations

type ParticipantOperations struct {
	RestPRServiceClient pr_client.RestPRServiceClient
	MockPRServiceClient pr_client.MockPRServiceClient

	CryptoServiceClient crypto_client.CryptoServiceClient
	// contains filtered or unexported fields
}

func CreateParticipantOperations

func CreateParticipantOperations() (ParticipantOperations, error)

func (ParticipantOperations) GetAccount

func (op ParticipantOperations) GetAccount(w http.ResponseWriter, req *http.Request)

func (ParticipantOperations) GetAccounts

func (op ParticipantOperations) GetAccounts(w http.ResponseWriter, req *http.Request)

Get account information from participant registry, parse it into list of accounts

func (ParticipantOperations) GetAllAssetsForParticipant

func (op ParticipantOperations) GetAllAssetsForParticipant(issuingDomain string) ([]*model.Asset, error)

func (ParticipantOperations) GetAssetsForParticipant

func (op ParticipantOperations) GetAssetsForParticipant(w http.ResponseWriter, request *http.Request)

func (ParticipantOperations) GetIssuedAssetsForParticipant

func (op ParticipantOperations) GetIssuedAssetsForParticipant(issuingDomain string) ([]*model.Asset, error)

func (ParticipantOperations) GetParticipantByDomain

func (op ParticipantOperations) GetParticipantByDomain(w http.ResponseWriter, request *http.Request)

func (ParticipantOperations) GetParticipantByQuery

func (op ParticipantOperations) GetParticipantByQuery(w http.ResponseWriter, request *http.Request)

func (ParticipantOperations) GetTrustedAssetsForParticipant

func (op ParticipantOperations) GetTrustedAssetsForParticipant(domain string) ([]*model.Asset, error)

func (ParticipantOperations) TrustedAssets

func (op ParticipantOperations) TrustedAssets(accountAddress string) ([]*model.Asset, error)

//GetWhiteListParticipants gets Participant domains in whitelist

func (op ParticipantOperations) GetWhiteListParticipants(w http.ResponseWriter, request *http.Request) {
	LOGGER.Infof("GetWhiteListParticipants")
	wwError, bytes := nc.GetWhiteListParticipants()
	if wwError.Code != "" {
		response.NotifyWWError(w, request, http.StatusNotFound, "API-"+wwError.Code, nil)
		return
	}

	response.Respond(w, http.StatusOK, bytes)
}

//AddWhiteListParticipant adds participant domain to whitelist //add next

func (op ParticipantOperations) AddWhiteListParticipant(w http.ResponseWriter, request *http.Request) {
	vars := mux.Vars(request)
	participantDomain := vars["participant_id"]

	LOGGER.Infof("AddWhiteListParticipant: participantDomain %v", participantDomain)

	if participantDomain == "" {
		response.NotifyWWError(w, request, http.StatusNotAcceptable, "API-1132",
			errors.New("Participant domain is required in query"))
		return
	}
	wwError := nc.AddWhiteListParticipant(participantDomain)
	if wwError.Code != "" {
		response.NotifyWWError(w, request, http.StatusNotAcceptable, "API-"+wwError.Code, nil)
		return
	}

	response.NotifySuccess(w, request, "Add WhiteList Participant OK")
}

//RemoveWhiteListParticipant - Removes participant domain from whitelist //add next

func (op ParticipantOperations) RemoveWhiteListParticipant(w http.ResponseWriter, request *http.Request) {
	vars := mux.Vars(request)
	participantDomain := vars["participant_id"]

	LOGGER.Infof("RemoveWhiteListParticipant: participantDomain %v", participantDomain)

	if participantDomain == "" {
		response.NotifyWWError(w, request, http.StatusNotAcceptable, "API-1132",
			errors.New("Participant domain is required in query"))
		return
	}

	wwError := nc.RemoveWhiteListParticipant(participantDomain)
	if wwError.Code != "" {
		response.NotifyWWError(w, request, http.StatusNotAcceptable, "API-"+wwError.Code, nil)
		return
	}

	response.NotifySuccess(w, request, "Remove WhiteList Participant OK")
}

// IsParticipantWhiteListed - checks if a participant is in white list

func (op ParticipantOperations) IsParticipantWhiteListed(w http.ResponseWriter, request *http.Request) {
	vars := mux.Vars(request)
	participantDomain := vars["participant_id"]

	LOGGER.Infof("IsParticipantWhiteListed: participantDomain %v", participantDomain)

	if participantDomain == "" {
		response.NotifyWWError(w, request, http.StatusNotAcceptable, "API-1132",
			errors.New("Participant domain is required in query"))
		return
	}

	isWhiteListed, wwError := nc.IsParticipantWhiteListed(participantDomain)
	if wwError.Code != "" {
		response.NotifyWWError(w, request, http.StatusNotFound, "API-"+wwError.Code, nil)
		return
	}

	response.NotifySuccess(w, request, strconv.FormatBool(isWhiteListed))
}

TrustedAssets - return trusted assets for the given accountAddres

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL