api/provision_broker.go
func (a *API) FetchProvisionBroker(cid CIDType) (*ProvisionBroker, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid provision broker request CID [none]")
	}

	brokerCID := string(*cid)

	matched, err := regexp.MatchString(config.ProvisionBrokerCIDRegex, brokerCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid provision broker request CID [%s]", brokerCID)
	}

	result, err := a.Get(brokerCID)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch broker provision request, received JSON: %s", string(result))
	}

	broker := &ProvisionBroker{}
	if err := json.Unmarshal(result, broker); err != nil {
		return nil, err
	}

	return broker, nil
}
func (a *API) FetchProvisionBroker(cid CIDType) (*ProvisionBroker, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid provision broker request CID [none]")
	}

	brokerCID := string(*cid)

	matched, err := regexp.MatchString(config.ProvisionBrokerCIDRegex, brokerCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid provision broker request CID [%s]", brokerCID)
	}

	result, err := a.Get(brokerCID)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch broker provision request, received JSON: %s", string(result))
	}

	broker := &ProvisionBroker{}
	if err := json.Unmarshal(result, broker); err != nil {
		return nil, err
	}

	return broker, nil
}
func ( a * API ) FetchProvisionBroker ( cid CIDType ) ( * ProvisionBroker , error ) { if cid == nil || * cid == " " { return nil , fmt . Errorf ( " " ) } brokerCID := string ( * cid ) matched , err := regexp . MatchString ( config . ProvisionBrokerCIDRegex , brokerCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , brokerCID ) } result , err := a . Get ( brokerCID ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( result ) ) } broker := & ProvisionBroker { } if err := json . Unmarshal ( result , broker ) ; err != nil { return nil , err } return broker , nil }
// FetchProvisionBroker retrieves provision broker [request] with passed cid.
FetchProvisionBroker retrieves provision broker [ request ] with passed cid .