Files
moloapp/src/google/runtime/calls.h
T

80 lines
4.3 KiB
C++
Raw Normal View History

#pragma once
// The ONE table of REST calls this module makes. Every row is checked against
// Google's Discovery document by tools/check_discovery.py. Code builds every
// URL from this table, never from a literal.
#include <string>
#include "clients/request.h"
#include "google/endpoints.h"
namespace molo::google::runtime {
enum class Call {
kCreate, kGet, kList, kPatch, kDelete, kQuery, kStreamQuery, kAsyncQuery,
kCancelAsyncQuery, kExecuteCode, kGetIamPolicy, kSetIamPolicy, kTestIamPermissions,
kOperationGet, kOperationList, kOperationCancel, kOperationDelete,
kRevisionGet, kRevisionList, kRevisionDelete, kRevisionQuery, kRevisionStreamQuery,
// Rows below were added from Discovery to close the gap list. Families of
// A2A gateway calls: Engine/EngineV1 hang off an engine, Revision/RevisionV1
// off a runtime revision; the V1 forms are `.../a2a/v1/...` routes.
kOperationWait, kRevisionQueryV1, kRevisionStreamQueryV1, kRevisionOperationGet,
kRevisionOperationList, kRevisionOperationCancel, kRevisionOperationWait,
kRevisionOperationDelete, kExampleOperationGet, kExampleOperationCancel,
kExampleOperationWait, kExampleOperationDelete, kFeedbackList, kFeedbackCreate, kFeedbackGet,
kFeedbackPatch, kFeedbackDelete, kFeedbackUpdateContext, kFeedbackGetContext,
kFeedbackOperationGet, kFeedbackOperationList, kFeedbackOperationCancel,
kFeedbackOperationWait, kFeedbackOperationDelete, kA2aTaskCreate, kA2aTaskAppendEvents,
kA2aTaskDelete, kA2aTaskList, kA2aTaskGet, kA2aTaskEventsList, kTaskRecordCreate,
kTaskRecordAppendEvents, kTaskRecordDelete, kTaskRecordList, kTaskRecordGet, kA2aEngineCard,
kA2aEngineExtendedAgentCard, kA2aEngineTasks, kA2aEngineTasksGetEngine,
kA2aEngineTasksPushConfigs, kA2aEngineTasksPushConfigsGetEngine, kA2aEngineTasksCancel,
kA2aEngineTasksSubscribe, kA2aEngineMessageSend, kA2aEngineMessageStream, kA2aEngineV1Card,
kA2aEngineV1ExtendedAgentCard, kA2aEngineV1Tasks, kA2aEngineV1TasksGetEngine,
kA2aEngineV1TasksPushConfigs, kA2aEngineV1TasksPushConfigsGetEngine, kA2aEngineV1TasksCancel,
kA2aEngineV1TasksSubscribe, kA2aEngineV1MessageSend, kA2aEngineV1MessageStream,
kA2aRevisionCard, kA2aRevisionExtendedAgentCard, kA2aRevisionTasks,
kA2aRevisionTasksGetEngine, kA2aRevisionTasksPushConfigs,
kA2aRevisionTasksPushConfigsGetEngine, kA2aRevisionTasksCancel, kA2aRevisionTasksSubscribe,
kA2aRevisionMessageSend, kA2aRevisionMessageStream, kA2aRevisionV1Card,
kA2aRevisionV1ExtendedAgentCard, kA2aRevisionV1Tasks, kA2aRevisionV1TasksGetEngine,
kA2aRevisionV1TasksPushConfigs, kA2aRevisionV1TasksPushConfigsGetEngine,
kA2aRevisionV1TasksCancel, kA2aRevisionV1TasksSubscribe, kA2aRevisionV1MessageSend,
kA2aRevisionV1MessageStream, kTaskStoreOperationGet, kTaskStoreOperationList,
kTaskStoreOperationCancel, kTaskStoreOperationWait, kTaskStoreOperationDelete,
kTaskRecordEventsList,
};
struct CallSpec {
Call call;
const char* http_method; // as in discovery: GET POST PATCH DELETE
const char* path; // discovery "path", e.g. "v1/{+name}:query"
const char* version; // "v1" or "v1beta1"
const char* rpc_id; // discovery method id
const char* body_fields; // comma list: request body fields we send
const char* query_params; // comma list: query parameters we send
};
struct SchemaFields {
const char* schema; // discovery schema name without the version prefix
const char* version; // "v1" or "v1beta1"
const char* fields; // comma list: fields we read or write
};
const CallSpec& spec_of(Call call);
clients::Method method_of(Call call);
// The table itself, for listing (demo, tests, conformance).
std::size_t call_count();
const CallSpec& spec_at(std::size_t index);
// Endpoint for the call's API version in a location. `beta` selects the
// v1beta1 twin of a v1 row (tools/check_discovery.py verifies every v1 row
// has the same method, path, rpc id and fields in v1beta1).
ServiceEndpoint endpoint_of(Call call, const std::string& location, bool beta = false);
// Path under the endpoint base: "/projects/.../reasoningEngines/x:query".
// `target` replaces the {+name}, {+parent} or {+resource} placeholder; `tail`
// replaces {+a2aEndpoint} (validated: segments of [A-Za-z0-9._:-], no "..").
std::string render(Call call, const std::string& target, const std::string& tail = "");
} // namespace molo::google::runtime