Search Objects
Use SearchObjects to retrieve a paginated snapshot of Objects that match your filters.
The operation evaluates the query when the request is received.
For initial state plus live changes, use Stream instead.
package main
import (
"connectrpc.com/connect"
"context"
"log"
wdmsdk "github.com/raft-tech/raft-wdm-sdk-go"
pb "github.com/raft-tech/raft-wdm-sdk-go/gen/raft/wdm/v1"
svc "github.com/raft-tech/raft-wdm-sdk-go/gen/raft/wdm/v1/service"
)
func main() {
cfg, err := wdmsdk.LoadConfig()
if err != nil {
log.Fatal(err)
}
client, err := wdmsdk.NewFromConfig(cfg)
if err != nil {
log.Fatal(err)
}
resp, err := client.ObjectService().SearchObjects(context.Background(), connect.NewRequest(&svc.SearchObjectsRequest{
Query: &svc.ObjectQuery{
Statuses: []pb.ObjectStatus{pb.ObjectStatus_OBJECT_STATUS_ACTIVE},
Affiliations: []pb.Affiliation{pb.Affiliation_AFFILIATION_FRIEND},
},
PageSize: 100,
}))
if err != nil {
log.Fatal(err)
}
for _, obj := range resp.Msg.GetObjects() {
log.Printf("found object: %s %s", obj.GetId(), obj.GetName())
}
}
import com.raft.wdm.Wdm;
import com.raft.wdm.raft.wdm.v1.Affiliation;
import com.raft.wdm.raft.wdm.v1.ObjectStatus;
import com.raft.wdm.raft.wdm.v1.service.ObjectQuery;
import com.raft.wdm.raft.wdm.v1.service.SearchObjectsRequest;
import com.raft.wdm.v1.WdmV1Client;
public final class SearchObjectsExample {
public static void main(String[] args) {
var options = Wdm.toOptions(Wdm.loadConfig(null, null));
try (var client = WdmV1Client.create(options)) {
var req = SearchObjectsRequest.newBuilder()
.setQuery(ObjectQuery.newBuilder()
.addStatuses(ObjectStatus.OBJECT_STATUS_ACTIVE)
.addAffiliations(Affiliation.AFFILIATION_FRIEND))
.setPageSize(100)
.build();
client.getObjectServiceBlocking()
.searchObjectsBlocking(req)
.execute();
}
}
}
import asyncio
from raft.wdm.v1 import assessment_pb2
from raft.wdm.v1 import object_pb2
from raft.wdm.v1.service import object_service_pb2
from raft.wdm.v1.service import query_pb2
import raft_wdm_sdk
async def main() -> None:
async with raft_wdm_sdk.Client.from_config(raft_wdm_sdk.load_config()) as client:
response = await client.object_service.search_objects(
object_service_pb2.SearchObjectsRequest(
query=query_pb2.ObjectQuery(
statuses=[object_pb2.OBJECT_STATUS_ACTIVE],
affiliations=[assessment_pb2.AFFILIATION_FRIEND],
),
page_size=100,
),
)
for obj in response.objects:
print(f"found object: {obj.id} {obj.name}")
asyncio.run(main())
import { create } from "@bufbuild/protobuf";
import { createClient, fromNodeConfig, loadConfig } from "@raft-tech/raft-wdm-sdk-typescript";
import { Affiliation } from "@raft-tech/raft-wdm-sdk-typescript/gen/raft/wdm/v1/assessment_pb.js";
import { ObjectStatus } from "@raft-tech/raft-wdm-sdk-typescript/gen/raft/wdm/v1/object_pb.js";
import { SearchObjectsRequestSchema } from "@raft-tech/raft-wdm-sdk-typescript/gen/raft/wdm/v1/service/object_service_pb.js";
const client = createClient(...fromNodeConfig(loadConfig()));
const response = await client.objectService.searchObjects(
create(SearchObjectsRequestSchema, {
query: {
statuses: [ObjectStatus.OBJECT_STATUS_ACTIVE],
affiliations: [Affiliation.AFFILIATION_FRIEND],
},
pageSize: 100,
}),
);
for (const object of response.objects) {
console.log(`found object: ${object.id} ${object.name}`);
}
curl -X POST "${RDP_SERVER_URL}/api/v1/wdm/objects/search" \
-H "X-API-KEY: ${RDP_API_KEY}" \
-H "Content-Type: application/json" \
--json @- <<JSON
{
"query": {
"statuses": ["OBJECT_STATUS_ACTIVE"],
"affiliations": ["AFFILIATION_FRIEND"]
},
"pageSize": 100
}
JSON
Query Criteria
Omit query to return all Objects.
When a field has multiple values, an Object can match any of them.
When the query uses multiple fields, an Object must match each field.
For example, this request returns active friendly surface Objects:
{
"query": {
"statuses": ["OBJECT_STATUS_ACTIVE"],
"affiliations": ["AFFILIATION_FRIEND"],
"environments": ["ENVIRONMENT_SURFACE"]
},
"pageSize": 100
}
The full contract is defined in the WDM protobuf spec.
In the WDM distribution, see raft/wdm/v1/service/object_service.proto for SearchObjectsRequest and raft/wdm/v1/service/query.proto for ObjectQuery.
Pagination
Results are returned in pages using an opaque cursor.
-
Omit
cursorto request the first page. -
Set
pageSizeto control the maximum Objects returned in one response. -
Pass
nextCursorfrom the response back ascursorto read the next page. -
Stop paging when
nextCursoris empty.
Treat nextCursor as opaque and do not parse it.