feat(clients): runtime: Agent Engine reasoningEngines client, discovery-checked call table, typed deployment spec, demo routes
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
#include "google/runtime/calls.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "google/errors.h"
|
||||
#include "google/resource.h"
|
||||
|
||||
namespace molo::google::runtime {
|
||||
|
||||
// CALLS-BEGIN (parsed by tools/check_discovery.py; one row per line)
|
||||
static const CallSpec kCalls[] = {
|
||||
{Call::kCreate, "POST", "v1/{+parent}/reasoningEngines", "v1", "aiplatform.projects.locations.reasoningEngines.create", "displayName,description,labels,spec,encryptionSpec", ""},
|
||||
{Call::kGet, "GET", "v1/{+name}", "v1", "aiplatform.projects.locations.reasoningEngines.get", "", ""},
|
||||
{Call::kList, "GET", "v1/{+parent}/reasoningEngines", "v1", "aiplatform.projects.locations.reasoningEngines.list", "", "filter,pageSize,pageToken"},
|
||||
{Call::kPatch, "PATCH", "v1/{+name}", "v1", "aiplatform.projects.locations.reasoningEngines.patch", "name,displayName,description,labels,spec", "updateMask"},
|
||||
{Call::kDelete, "DELETE", "v1/{+name}", "v1", "aiplatform.projects.locations.reasoningEngines.delete", "", "force"},
|
||||
{Call::kQuery, "POST", "v1/{+name}:query", "v1", "aiplatform.projects.locations.reasoningEngines.query", "input,classMethod", ""},
|
||||
{Call::kStreamQuery, "POST", "v1/{+name}:streamQuery", "v1", "aiplatform.projects.locations.reasoningEngines.streamQuery", "input,classMethod", ""},
|
||||
{Call::kAsyncQuery, "POST", "v1/{+name}:asyncQuery", "v1", "aiplatform.projects.locations.reasoningEngines.asyncQuery", "inputGcsUri,outputGcsUri", ""},
|
||||
{Call::kCancelAsyncQuery, "POST", "v1/{+name}:cancelAsyncQuery", "v1", "aiplatform.projects.locations.reasoningEngines.cancelAsyncQuery", "operationName", ""},
|
||||
{Call::kExecuteCode, "POST", "v1/{+name}:executeCode", "v1", "aiplatform.projects.locations.reasoningEngines.executeCode", "inputs", ""},
|
||||
{Call::kGetIamPolicy, "POST", "v1/{+resource}:getIamPolicy", "v1", "aiplatform.projects.locations.reasoningEngines.getIamPolicy", "", "options.requestedPolicyVersion"},
|
||||
{Call::kSetIamPolicy, "POST", "v1/{+resource}:setIamPolicy", "v1", "aiplatform.projects.locations.reasoningEngines.setIamPolicy", "policy", ""},
|
||||
{Call::kTestIamPermissions, "POST", "v1/{+resource}:testIamPermissions", "v1", "aiplatform.projects.locations.reasoningEngines.testIamPermissions", "", "permissions"},
|
||||
{Call::kOperationGet, "GET", "v1/{+name}", "v1", "aiplatform.projects.locations.reasoningEngines.operations.get", "", ""},
|
||||
{Call::kOperationList, "GET", "v1/{+name}/operations", "v1", "aiplatform.projects.locations.reasoningEngines.operations.list", "", "filter,pageSize,pageToken"},
|
||||
{Call::kOperationCancel, "POST", "v1/{+name}:cancel", "v1", "aiplatform.projects.locations.reasoningEngines.operations.cancel", "", ""},
|
||||
{Call::kOperationDelete, "DELETE", "v1/{+name}", "v1", "aiplatform.projects.locations.reasoningEngines.operations.delete", "", ""},
|
||||
{Call::kRevisionGet, "GET", "v1beta1/{+name}", "v1beta1", "aiplatform.projects.locations.reasoningEngines.runtimeRevisions.get", "", ""},
|
||||
{Call::kRevisionList, "GET", "v1beta1/{+parent}/runtimeRevisions", "v1beta1", "aiplatform.projects.locations.reasoningEngines.runtimeRevisions.list", "", "filter,pageSize,pageToken"},
|
||||
{Call::kRevisionDelete, "DELETE", "v1beta1/{+name}", "v1beta1", "aiplatform.projects.locations.reasoningEngines.runtimeRevisions.delete", "", ""},
|
||||
{Call::kRevisionQuery, "POST", "v1beta1/{+name}:query", "v1beta1", "aiplatform.projects.locations.reasoningEngines.runtimeRevisions.query", "input,classMethod", ""},
|
||||
{Call::kRevisionStreamQuery, "POST", "v1beta1/{+name}:streamQuery", "v1beta1", "aiplatform.projects.locations.reasoningEngines.runtimeRevisions.streamQuery", "input,classMethod", ""},
|
||||
};
|
||||
// CALLS-END
|
||||
|
||||
// SCHEMAS-BEGIN (parsed by tools/check_discovery.py; one row per line)
|
||||
static const SchemaFields kSchemas[] = {
|
||||
{"ReasoningEngine", "v1", "name,displayName,description,labels,spec,etag,createTime,updateTime,encryptionSpec,contextSpec"},
|
||||
{"ReasoningEngineSpec", "v1", "agentFramework,packageSpec,containerSpec,sourceCodeSpec,deploymentSpec,buildSpec,identityType,serviceAccount,effectiveIdentity,classMethods"},
|
||||
{"ReasoningEngineSpecPackageSpec", "v1", "pythonVersion,pickleObjectGcsUri,dependencyFilesGcsUri,requirementsGcsUri"},
|
||||
{"ReasoningEngineSpecContainerSpec", "v1", "imageUri,port"},
|
||||
{"ReasoningEngineSpecSourceCodeSpec", "v1", "pythonSpec,inlineSource,developerConnectSource,imageSpec,agentConfigSource"},
|
||||
{"ReasoningEngineSpecSourceCodeSpecPythonSpec", "v1", "version,entrypointModule,entrypointObject,requirementsFile"},
|
||||
{"ReasoningEngineSpecBuildSpec", "v1", "serviceAccount,workerPool"},
|
||||
{"ReasoningEngineSpecDeploymentSpec", "v1", "env,secretEnv,resourceLimits,minInstances,maxInstances,containerConcurrency,pscInterfaceConfig,keepAliveProbe,agentGatewayConfig"},
|
||||
{"EnvVar", "v1", "name,value"},
|
||||
{"SecretEnvVar", "v1", "name,secretRef"},
|
||||
{"SecretRef", "v1", "secret,version"},
|
||||
{"EncryptionSpec", "v1", "kmsKeyName"},
|
||||
{"ListReasoningEnginesResponse", "v1", "reasoningEngines,nextPageToken"},
|
||||
{"QueryReasoningEngineResponse", "v1", "output"},
|
||||
{"ExecuteCodeResponse", "v1", "outputs"},
|
||||
{"ReasoningEngine", "v1beta1", "trafficConfig,revisionGarbageCollectionStrategy"},
|
||||
{"ReasoningEngineRuntimeRevision", "v1beta1", "name,state,createTime,spec"},
|
||||
{"ListReasoningEngineRuntimeRevisionsResponse", "v1beta1", "reasoningEngineRuntimeRevisions,nextPageToken"},
|
||||
{"ReasoningEngineSpecDeploymentSpec", "v1beta1", "agentServerMode"},
|
||||
{"ReasoningEngineSpec", "v1beta1", "agentCard"},
|
||||
};
|
||||
// SCHEMAS-END
|
||||
|
||||
const CallSpec& spec_of(Call call) {
|
||||
for (const CallSpec& s : kCalls)
|
||||
if (s.call == call) return s;
|
||||
throw GoogleError::invalid("unknown call");
|
||||
}
|
||||
|
||||
clients::Method method_of(Call call) {
|
||||
const char* m = spec_of(call).http_method;
|
||||
if (!std::strcmp(m, "GET")) return clients::Method::kGet;
|
||||
if (!std::strcmp(m, "POST")) return clients::Method::kPost;
|
||||
if (!std::strcmp(m, "PATCH")) return clients::Method::kPatch;
|
||||
return clients::Method::kDelete;
|
||||
}
|
||||
|
||||
ServiceEndpoint endpoint_of(Call call, const std::string& location) {
|
||||
return std::strcmp(spec_of(call).version, "v1beta1") == 0
|
||||
? endpoints::aiplatform_beta(location)
|
||||
: endpoints::aiplatform(location);
|
||||
}
|
||||
|
||||
std::string render(Call call, const std::string& target) {
|
||||
std::string path = spec_of(call).path;
|
||||
path.erase(0, path.find('/') + 1); // drop the version prefix; the endpoint has it
|
||||
for (const char* key : {"{+name}", "{+parent}", "{+resource}"}) {
|
||||
auto at = path.find(key);
|
||||
if (at != std::string::npos) path.replace(at, std::strlen(key), target);
|
||||
}
|
||||
return "/" + path;
|
||||
}
|
||||
|
||||
} // namespace molo::google::runtime
|
||||
Reference in New Issue
Block a user