// GetCpCode populates the *CpCode with it's data
//
// API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getacpcode
// Endpoint: GET /papi/v1/cpcodes/{cpcodeId}{?contractId,groupId}
337688
func (cpcode *CpCode) GetCpCode() error {
	req, err := client.NewRequest(
		Config,
		"GET",
		fmt.Sprintf(
			"/papi/v1/cpcodes/%s?contractId=%s&groupId=%s",
			cpcode.CpcodeID,
			cpcode.parent.Contract.ContractID,
			cpcode.parent.Group.GroupID,
		),
		nil,
	)
	if err != nil {
		return err
	}

	res, err := client.Do(Config, req)

	if client.IsError(res) {
		return client.NewAPIError(res)
	}

	newCpcodes := NewCpCodes(nil, nil)
	if err = client.BodyJSON(res, newCpcodes); err != nil {
		return err
	}
	if len(newCpcodes.CpCodes.Items) == 0 {
		return fmt.Errorf("CP Code \"%s\" not found", cpcode.CpcodeID)
	}

	cpcode.CpcodeID = newCpcodes.CpCodes.Items[0].CpcodeID
	cpcode.CpcodeName = newCpcodes.CpCodes.Items[0].CpcodeName
	cpcode.ProductID = newCpcodes.CpCodes.Items[0].ProductID
	cpcode.ProductIDs = newCpcodes.CpCodes.Items[0].ProductIDs
	cpcode.CreatedDate = newCpcodes.CpCodes.Items[0].CreatedDate

	cpcode.parent.AddCpCode(cpcode)

	return nil
}
142978
func Code(err error) vtrpcpb.Code {
	if err == nil {
		return vtrpcpb.Code_OK
	}
	if err, ok := err.(*fundamental); ok {
		return err.code
	}

	cause := Cause(err)
	if cause != err && cause != nil {
		// If we did not find an error code at the outer level, let's find the cause and check it's code
		return Code(cause)
	}

	// Handle some special cases.
	switch err {
	case context.Canceled:
		return vtrpcpb.Code_CANCELED
	case context.DeadlineExceeded:
		return vtrpcpb.Code_DEADLINE_EXCEEDED
	}
	return vtrpcpb.Code_UNKNOWN
}
846143
func (cifs *CCInfoFSImpl) GetChaincode(ccname string, ccversion string) (CCPackage, error) {
	return cifs.GetChaincodeFromPath(ccname, ccversion, chaincodeInstallPath)
}
426067
func (c *Client) GetCodes(codeListID string, edition string) (codes CodesResults, err error) {
	url := fmt.Sprintf("%s/code-lists/%s/editions/%s/codes", c.url, codeListID, edition)
	resp, err := c.cli.Get(context.Background(), url)
	if err != nil {
		return
	}
	defer resp.Body.Close()

	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return
	}

	err = json.Unmarshal(b, &codes)
	if err != nil {
		return
	}
	return codes, nil
}
1209656
func (ec *EthereumClient) GetCodeAt(ctx *Context, account *Address, number int64) (code []byte, _ error) {
	if number < 0 {
		return ec.client.CodeAt(ctx.context, account.address, nil)
	}
	return ec.client.CodeAt(ctx.context, account.address, big.NewInt(number))
}
155004
func (v *Xception) GetErrorCode() (o int32) {
	if v != nil && v.ErrorCode != nil {
		return *v.ErrorCode
	}

	return
}
664845
func (r *RDBDriver) GetByCpeURI(uri string) ([]models.CveDetail, error) {
	cveIDs, err := r.GetCveIDsByCpeURI(uri)
	if err != nil {
		return nil, err
	}

	cveDetails, err := r.GetMulti(cveIDs)
	if err != nil {
		return nil, err
	}

	// Convert from map to array
	details := make([]models.CveDetail, len(cveDetails))
	i := 0
	for _, d := range cveDetails {
		details[i] = d
		i++
		log.Debugf("%s", d.CveID)
	}
	return details, nil
}
202113
func (r *RPCWrapper) GetRPCClient(contextID string) (*RPCHdl, error) {

	r.Lock()
	defer r.Unlock()

	val, err := r.rpcClientMap.Get(contextID)
	if err != nil {
		return nil, err
	}

	return val.(*RPCHdl), nil
}
1223129
func (c *Client) GetApp(appID string) (*ct.App, error) {
	app := &ct.App{}
	return app, c.Get(fmt.Sprintf("/apps/%s", appID), app)
}
367257
func GetCpCodes(contract *Contract, group *Group) (*CpCodes, error) {
	cpcodes := NewCpCodes(contract, group)
	if err := cpcodes.GetCpCodes(); err != nil {
		return nil, err
	}

	return cpcodes, nil
}
1015632
func (pssapi *API) GetPublicKey() (keybytes hexutil.Bytes) {
	key := pssapi.Pss.PublicKey()
	keybytes = crypto.FromECDSAPub(key)
	return keybytes
}
851799
func (o *InvitationManager) GetByCode(code string) (invite *JoinOrganizationInvitation, err error) {
	qry := bson.M{
		"code": code,
	}
	err = o.collection.Find(qry).One(&invite)
	return
}
886493
func (p *ProjectCard) GetProjectID() int64 {
	if p == nil || p.ProjectID == nil {
		return 0
	}
	return *p.ProjectID
}
1005253
func (o Options) Get(key OptionCode) ([][]byte, error) {
	// Check for value by key.
	v, ok := o[key]
	if !ok {
		return nil, ErrOptionNotPresent
	}

	// Some options can actually have zero length (OptionRapidCommit), so
	// just return an empty byte slice if this is the case.
	if len(v) == 0 {
		return [][]byte{{}}, nil
	}
	return v, nil
}
186189
func (fp *formatParser) codeCode(i int, r rune) error {
	fp.processCode(i)
	fp.start = i
	fp.code = (*formatParser).freshCode
	fp.next = (*formatParser).freshNext
	fp.end = (*formatParser).freshEnd
	return nil
}
1125590
func (d *Domain) GetCPUStats(startCpu int, nCpus uint, flags uint32) ([]DomainCPUStats, error) {
	var err C.virError
	if nCpus == 0 {
		if startCpu == -1 {
			nCpus = 1
		} else {
			ret := C.virDomainGetCPUStatsWrapper(d.ptr, nil, 0, 0, 0, 0, &err)
			if ret == -1 {
				return []DomainCPUStats{}, makeError(&err)
			}
			nCpus = uint(ret)
		}
	}

	ret := C.virDomainGetCPUStatsWrapper(d.ptr, nil, 0, C.int(startCpu), C.uint(nCpus), 0, &err)
	if ret == -1 {
		return []DomainCPUStats{}, makeError(&err)
	}
	cnparams := C.int(ret)

	var cnallocparams C.int
	if startCpu == -1 {
		cnallocparams = cnparams
	} else {
		cnallocparams = cnparams * C.int(nCpus)
	}
	cparams := typedParamsNew(cnallocparams)
	defer C.virTypedParamsFree(cparams, cnallocparams)
	ret = C.virDomainGetCPUStatsWrapper(d.ptr, cparams, C.uint(cnparams), C.int(startCpu), C.uint(nCpus), C.uint(flags), &err)
	if ret == -1 {
		return []DomainCPUStats{}, makeError(&err)
	}

	stats := make([]DomainCPUStats, nCpus)
	for i := 0; i < int(nCpus); i++ {
		coffset := C.int(i) * cnparams
		info := getCPUStatsFieldInfo(&stats[i])
		var cparamscpu *C.virTypedParameter
		cparamscpu = (*C.virTypedParameter)(unsafe.Pointer(uintptr(unsafe.Pointer(cparams)) +
			(unsafe.Sizeof(*cparams) * uintptr(coffset))))
		_, gerr := typedParamsUnpack(cparamscpu, cnparams, info)
		if gerr != nil {
			return []DomainCPUStats{}, gerr
		}
	}
	return stats, nil
}
418695
func (is *identityMapperImpl) GetPKIidOfCert(identity api.PeerIdentityType) common.PKIidType {
	return is.mcs.GetPKIidOfCert(identity)
}