46 lines
1.7 KiB
C++
46 lines
1.7 KiB
C++
#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,
|
||
|
|
};
|
||
|
|
|
||
|
|
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);
|
||
|
|
// Endpoint for the call's API version in a location.
|
||
|
|
ServiceEndpoint endpoint_of(Call call, const std::string& location);
|
||
|
|
// Path under the endpoint base: "/projects/.../reasoningEngines/x:query".
|
||
|
|
// `target` replaces the {+name}, {+parent} or {+resource} placeholder.
|
||
|
|
std::string render(Call call, const std::string& target);
|
||
|
|
|
||
|
|
} // namespace molo::google::runtime
|