// ExportEntities allocates unique, remote entity IDs for the given entities in the local model.
505870
func (api *RemoteRelationsAPI) ExportEntities(entities params.Entities) (params.TokenResults, error) {
	results := params.TokenResults{
		Results: make([]params.TokenResult, len(entities.Entities)),
	}
	for i, entity := range entities.Entities {
		tag, err := names.ParseTag(entity.Tag)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		token, err := api.st.ExportLocalEntity(tag)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			if !errors.IsAlreadyExists(err) {
				continue
			}
		}
		results.Results[i].Token = token
	}
	return results, nil
}
741216
func (a PGPGenArg) ExportTo(ret *keybase1.PGPKeyGenArg) {
	ret.PrimaryBits = a.PrimaryBits
	ret.SubkeyBits = a.SubkeyBits
	ret.CreateUids = keybase1.PGPCreateUids{Ids: a.Ids.Export()}
	return
}
802834
func (vtg *VTGate) ExecuteEntityIds(ctx context.Context, request *vtgatepb.ExecuteEntityIdsRequest) (response *vtgatepb.ExecuteEntityIdsResponse, err error) {
	defer vtg.server.HandlePanic(&err)
	ctx = withCallerIDContext(ctx, request.CallerId)
	result, err := vtg.server.ExecuteEntityIds(ctx,
		request.Query.Sql,
		request.Query.BindVariables,
		request.Keyspace,
		request.EntityColumnName,
		request.EntityKeyspaceIds,
		request.TabletType,
		request.Session,
		request.NotInTransaction,
		request.Options)
	return &vtgatepb.ExecuteEntityIdsResponse{
		Result:  sqltypes.ResultToProto3(result),
		Session: request.Session,
		Error:   vterrors.ToVTRPC(err),
	}, nil
}
405285
func (s *GlobalStore) Export(w io.Writer) (n int, err error) {
	s.mu.RLock()
	defer s.mu.RUnlock()

	tw := tar.NewWriter(w)
	defer tw.Close()

	buf := bytes.NewBuffer(make([]byte, 0, 1024))
	encoder := json.NewEncoder(buf)
	for key, addrs := range s.keyNodes {
		buf.Reset()
		if err = encoder.Encode(mock.ExportedChunk{
			Addrs: addrs,
			Data:  s.data[key],
		}); err != nil {
			return n, err
		}

		data := buf.Bytes()
		hdr := &tar.Header{
			Name: common.Bytes2Hex([]byte(key)),
			Mode: 0644,
			Size: int64(len(data)),
		}
		if err := tw.WriteHeader(hdr); err != nil {
			return n, err
		}
		if _, err := tw.Write(data); err != nil {
			return n, err
		}
		n++
	}
	return n, err
}
555859
func (m *Model) Annotations(entity GlobalEntity) (map[string]string, error) {
	doc := new(annotatorDoc)
	annotations, closer := m.st.db().GetCollection(annotationsC)
	defer closer()
	err := annotations.FindId(entity.globalKey()).One(doc)
	if err == mgo.ErrNotFound {
		// Returning an empty map if there are no annotations.
		return make(map[string]string), nil
	}
	if err != nil {
		return nil, errors.Trace(err)
	}
	return doc.Annotations, nil
}
1052329
func (vrsConnection *VRSConnection) GetEntityPorts(uuid string) ([]string, error) {

	readRowArgs := ovsdb.ReadRowArgs{
		Columns:   []string{ovsdb.NuageVMTableColumnPorts},
		Condition: []string{ovsdb.NuageVMTableColumnVMUUID, "==", uuid},
	}

	row, err := vrsConnection.vmTable.ReadRow(vrsConnection.ovsdbClient, readRowArgs)
	if err != nil {
		return []string{}, fmt.Errorf("Unable to get port information for the VM")
	}

	return ovsdb.UnMarshallOVSStringSet(row[ovsdb.NuageVMTableColumnPorts])
}
1244921
func FromThriftToEntityDefinition(ed *dosarpc.EntityDefinition) *dosa.EntityDefinition {
	fields := make([]*dosa.ColumnDefinition, len(ed.FieldDescs))
	i := 0
	for k, v := range ed.FieldDescs {
		fields[i] = &dosa.ColumnDefinition{
			Name: k,
			Type: RPCTypeToClientType(*v.Type),
			// TODO Tag
		}
		i++
	}

	indexes := make(map[string]*dosa.IndexDefinition)
	for name, index := range ed.Indexes {
		indexes[name] = &dosa.IndexDefinition{
			Key: FromThriftToPrimaryKey(index.Key),
		}
	}

	etlState := dosa.EtlOff
	if ed.Etl != nil {
		etlState = fromThriftToETLState(ed.Etl)
	}

	return &dosa.EntityDefinition{
		Name:    *ed.Name,
		Columns: fields,
		Key:     FromThriftToPrimaryKey(ed.PrimaryKey),
		Indexes: indexes,
		ETL:     etlState,
	}
}
1283299
func (s *FieldLevelEncryptionProfileSummary) SetEncryptionEntities(v *EncryptionEntities) *FieldLevelEncryptionProfileSummary {
	s.EncryptionEntities = v
	return s
}
1295347
func (res *Resolver) ExecuteEntityIds(
	ctx context.Context,
	sql string,
	bindVariables map[string]*querypb.BindVariable,
	keyspace string,
	entityColumnName string,
	entityKeyspaceIDs []*vtgatepb.ExecuteEntityIdsRequest_EntityId,
	tabletType topodatapb.TabletType,
	session *vtgatepb.Session,
	notInTransaction bool,
	options *querypb.ExecuteOptions,
) (*sqltypes.Result, error) {
	// Unpack the entityKeyspaceIDs into []ids and []Destination
	ids := make([]*querypb.Value, len(entityKeyspaceIDs))
	destinations := make([]key.Destination, len(entityKeyspaceIDs))
	for i, eki := range entityKeyspaceIDs {
		ids[i] = &querypb.Value{
			Type:  eki.Type,
			Value: eki.Value,
		}
		destinations[i] = key.DestinationKeyspaceID(eki.KeyspaceId)
	}

	rss, values, err := res.resolver.ResolveDestinations(
		ctx,
		keyspace,
		tabletType,
		ids,
		destinations)
	if err != nil {
		return nil, err
	}
	for {
		sqls, bindVars := buildEntityIds(values, sql, entityColumnName, bindVariables)
		qr, err := res.scatterConn.ExecuteEntityIds(
			ctx,
			rss,
			sqls,
			bindVars,
			tabletType,
			NewSafeSession(session),
			notInTransaction,
			options)
		if isRetryableError(err) {
			newRss, newValues, err := res.resolver.ResolveDestinations(
				ctx,
				keyspace,
				tabletType,
				ids,
				destinations)
			if err != nil {
				return nil, err
			}
			if !srvtopo.ResolvedShardsEqual(rss, newRss) || !srvtopo.ValuesEqual(values, newValues) {
				// Retry if resharding happened.
				rss = newRss
				values = newValues
				continue
			}
		}
		if err != nil {
			return nil, err
		}
		return qr, err
	}
}
439269
func (c *Client) Datastores(ctx context.Context) ([]*mo.Datastore, error) {
	_, datacenter, err := c.finder(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}
	folders, err := datacenter.Folders(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}

	es, err := c.lister(folders.DatastoreFolder.Reference()).List(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var datastores []*mo.Datastore
	for _, e := range es {
		switch o := e.Object.(type) {
		case mo.Datastore:
			datastores = append(datastores, &o)
		}
	}
	return datastores, nil
}
644690
func ExportToJSON(schema *Schema, outpath string) error {
	out, file, _, err := outputWriter(outpath, string(schema.Name), ".json")
	if err != nil {
		return err
	}
	err = WriteJSON(schema, out)
	if file != nil {
		file.Close()
	}
	return err
}
819866
func (db *database) SaveEntity(e Entity) error {
	b, err := json.Marshal(e)

	if err != nil {
		return err
	}

	return db.storage.Set(toEntityKey(e.Name), b)
}
1247529
func serializeProperties(props []datastore.Property, exists bool) ([]byte, error) {
	// NOTE: We use a separate exists bool to support nil-props for existing structs
	if !exists {
		return []byte{0, 0, 0, 0}, nil
	}

	buf := getBuffer()
	defer freeBuffer(buf)

	// Serialize the entity header
	header := serializeEntityHeader(len(props), entityExists)
	headerBytes := make([]byte, 4)
	binary.LittleEndian.PutUint32(headerBytes, header)
	buf.Write(headerBytes)

	// Serialize the properties
	for i := range props {
		if err := serializeProperty(buf, &props[i]); err != nil {
			return nil, err
		}
	}

	output := make([]byte, buf.Len())
	copy(output, buf.Bytes())
	return output, nil
}
814966
func (s *FieldLevelEncryptionProfileConfig) SetEncryptionEntities(v *EncryptionEntities) *FieldLevelEncryptionProfileConfig {
	s.EncryptionEntities = v
	return s
}
1149475
func (c *Client) GetExports(ctx context.Context) (ExportList, error) {
	return api.ExportsList(ctx, c.API)
}
1128780
func (p *Polyline) AddNestedEntities(entities EntitySlice) {
	for _, entity := range entities {
		if vertex, ok := entity.(*Vertex); ok {
			p.Vertices = append(p.Vertices, vertex)
		} else {
			core.Log.Printf(
				"Skipping entity %v. Polylines can only contain Vertex entities.",
				entity)
		}
	}
}
582767
func (ckf ComputedKeyFamily) Export() []keybase1.PublicKey {
	var exportedKeys []keybase1.PublicKey
	for _, key := range ckf.GetAllActiveSibkeys() {
		exportedKeys = append(exportedKeys, ckf.exportPublicKey(key))
	}
	for _, key := range ckf.GetAllActiveSubkeys() {
		exportedKeys = append(exportedKeys, ckf.exportPublicKey(key))
	}
	sort.Sort(PublicKeyList(exportedKeys))
	return exportedKeys
}