mirror of
https://github.com/hanzo-cpp/sdk.git
synced 2026-11-20 19:55:32 +00:00
The projection was 113 commits behind the document it claims to describe, and `generate.py --all --check` reported every one of the thirteen clients DRIFTED — the same +19 models in each, because they all fell behind the same emission. Regenerated in place from hanzo-inc/cloud openapi.yaml at 939b09d4 (sha256 087024f6…), which is the only description of this API that cannot name a route the binary does not serve. `--check` is clean across all thirteen after. .spec-lock moved with the code. The generator READS that file and never writes it — hanzoai/ci`s lane does — so a hand run leaves every lock naming the previous document. A lock that disagrees with the tree beside it is worse than no lock: the next `--check` without `--spec` fetches what production serves, compares it to a digest that was already wrong, and reports drift that is really staleness.
174 lines
14 KiB
C++
174 lines
14 KiB
C++
/**
|
|
* Hanzo Cloud API
|
|
* The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
*
|
|
* The version of the OpenAPI document: v1
|
|
*
|
|
* NOTE: This class is auto generated by OpenAPI-Generator 7.14.0.
|
|
* https://openapi-generator.tech
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
/*
|
|
* LinkApi.h
|
|
*
|
|
*
|
|
*/
|
|
|
|
#ifndef HANZO_API_LinkApi_H_
|
|
#define HANZO_API_LinkApi_H_
|
|
|
|
|
|
|
|
#include "hanzo/ApiClient.h"
|
|
|
|
#include "hanzo/model/AccountsUsage.h"
|
|
#include "hanzo/model/BoardResp.h"
|
|
#include "hanzo/model/DeviceView.h"
|
|
#include "hanzo/model/EnrollReq.h"
|
|
#include "hanzo/model/IngestReq.h"
|
|
#include "hanzo/model/IngestResp.h"
|
|
#include "hanzo/model/LinkList.h"
|
|
#include "hanzo/model/LinkView.h"
|
|
#include "hanzo/model/RevokeResp.h"
|
|
#include "hanzo/model/RoutePlan.h"
|
|
#include "hanzo/model/SummaryResp.h"
|
|
#include <cpprest/details/basic_types.h>
|
|
#include <boost/optional.hpp>
|
|
|
|
namespace hanzo {
|
|
namespace api {
|
|
|
|
using namespace hanzo::model;
|
|
|
|
|
|
|
|
class LinkApi
|
|
{
|
|
public:
|
|
|
|
explicit LinkApi( std::shared_ptr<const ApiClient> apiClient );
|
|
|
|
virtual ~LinkApi();
|
|
|
|
/// <summary>
|
|
/// Logs out one account and stops the sessions it was running.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Logs out one account and stops the sessions it was running. It revokes a single linked account and stops the agent sessions that ran under it, answering with the revoked row and how many sessions stopped. The link is RETAINED with a revoked status rather than deleted, so its usage history and the audit trail survive the log-out — which also means a revoked account still appears in the list, and is excluded from the route plan rather than absent from it. The session stop is narrowed to the revoking user's own sessions on that device, provider and account, and a stop that fails does not fail the revoke: the revoked row is the durable truth. An id that does not exist, or belongs to another user or org, is the same 404.
|
|
/// </remarks>
|
|
/// <param name="id">ID is the link to act on, from the path. It is scoped to the caller, so another user's or org's id is a 404.</param>
|
|
pplx::task<std::shared_ptr<RevokeResp>> deleteLinkById(
|
|
utility::string_t id
|
|
) const;
|
|
/// <summary>
|
|
/// Lists your linked accounts and the devices they sit on.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Lists your linked accounts and the devices they sit on. It answers the caller's own links plus a devices projection of the same rows folded per machine — the cross-machine \"AI Providers / Accounts\" view. A device is a projection, not a stored entity: its labels come from its most-recently-seen account, so there is no device to create and none to garbage-collect. Revoked links are INCLUDED rather than dropped, because a logged-out account keeps its usage history and audit trail. Scoped to the caller: a validated principal and a non-empty org, else 403.
|
|
/// </remarks>
|
|
pplx::task<std::shared_ptr<LinkList>> getLink(
|
|
) const;
|
|
/// <summary>
|
|
/// Reads one linked account.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Reads one linked account. It answers a single link — its device, provider, account, plan, how it bills, its status and its latest usage snapshot. An id that does not exist, or belongs to another user or org, is the same 404: the scope is a bound predicate on the read, so a wrong id and a foreign id are indistinguishable and neither confirms the other's existence. The static paths on this collection — route, usage, devices — register before this one and win first-match, so a link whose id collided with one of those words could not be addressed here.
|
|
/// </remarks>
|
|
/// <param name="id">ID is the link to act on, from the path. It is scoped to the caller, so another user's or org's id is a 404.</param>
|
|
pplx::task<std::shared_ptr<LinkView>> getLinkById(
|
|
utility::string_t id
|
|
) const;
|
|
/// <summary>
|
|
/// Shows one machine: its accounts, usage and live sessions.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Shows one machine: its accounts, usage and live sessions. It answers one device — its host and OS labels, every account the caller has signed in on that machine with its latest usage, and how many agent sessions the caller currently has running on it. The device labels come from the most-recently-seen account, since a device is a projection of its links rather than a row of its own. A machine with none of the caller's accounts is 404, which is also the answer when the machine belongs to someone else — the scope makes the two indistinguishable, deliberately. The session count reports 0 where the agent plane is not mounted rather than failing the read.
|
|
/// </remarks>
|
|
/// <param name="machine">Machine is the machine to act on, from the path. It is scoped to the caller, so a machine with none of the caller's accounts is a 404.</param>
|
|
pplx::task<std::shared_ptr<DeviceView>> getLinkDevicesByMachine(
|
|
utility::string_t machine
|
|
) const;
|
|
/// <summary>
|
|
/// Gets the failover order across your linked accounts.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Gets the failover order across your linked accounts. It answers an ordered redundancy plan over the caller's LINKED (not revoked) accounts: each candidate with its remaining rate-limit headroom, whether it is routable right now, how it BILLS (plan or commerce), and a reason when it is not — plus the primary to try first. It is what lets a router fail over from one subscription to another and fall back to the metered API as the always-available backstop, knowing the cost consequence before it dials. It is POLICY, not execution: the plan is computed purely from the usage snapshots already in the registry, never by probing a provider, so it is a total function of the links and costs nothing to ask for. Actually dialing, detecting a live 429 and advancing to the next candidate belongs to the caller. A link with no snapshot counts as full headroom.
|
|
/// </remarks>
|
|
pplx::task<std::shared_ptr<RoutePlan>> getLinkRoute(
|
|
) const;
|
|
/// <summary>
|
|
/// Shows one provider account's own usage dashboard.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Shows one provider account's own usage dashboard. It answers the time series for a SINGLE provider account — the windows in range plus the currently-open ones — as that provider's own meter reported it: \"my plan is 47% through its 6h window, resets at 14:20\". current is the newest instance of each lane (the headline); windows is the history behind it, both computed from ONE deduped read. provider is required; an unknown window class or range is 400, never a quiet fallback to a different one. When no series is available the response is a 200 with available:false and empty lists — an honest \"we have no data\", which is a different claim from zero usage.
|
|
/// </remarks>
|
|
/// <param name="provider">Provider is the provider whose meter to read. Required. (optional, default to utility::conversions::to_string_t(""))</param>
|
|
/// <param name="account">Account narrows to one account when a user has several with the provider. (optional, default to utility::conversions::to_string_t(""))</param>
|
|
/// <param name="window">Window selects a window class: 6h, day, week or month. Empty reads all. (optional, default to utility::conversions::to_string_t(""))</param>
|
|
/// <param name="range">Range is the period, one of 1h, 24h, 7d or 30d; empty means 24h, and an unknown label is 400, never a quiet fallback. (optional, default to utility::conversions::to_string_t(""))</param>
|
|
pplx::task<std::shared_ptr<BoardResp>> getLinkUsage(
|
|
boost::optional<utility::string_t> provider,
|
|
boost::optional<utility::string_t> account,
|
|
boost::optional<utility::string_t> window,
|
|
boost::optional<utility::string_t> range
|
|
) const;
|
|
/// <summary>
|
|
/// Breaks down what the gateway routed through each of your accounts.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Breaks down what the gateway routed through each of your accounts. It answers one row per linked account the GATEWAY actually routed through, plus their total — requests, prompt and completion tokens, and cost. This is the routed ledger, the read twin of the counter the router writes, and it is distinct from both of its neighbours: not the device collector's plan snapshots, and not the org money ledger. The source and scope fields on the response say so on every payload. The same shape answers in the billing namespace, from one shaping function, so the two mounts cannot drift.
|
|
/// </remarks>
|
|
pplx::task<std::shared_ptr<AccountsUsage>> getLinkUsageAccounts(
|
|
) const;
|
|
/// <summary>
|
|
/// Shows plan consumption and Hanzo spend side by side.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Shows plan consumption and Hanzo spend side by side. It answers the global usage board over one window: the caller's own linked accounts, metered from each provider's own login, alongside their org's Hanzo-routed inference. These come from different ledgers and mean different things, so every row is LABELLED by source, by scope and by availability, and THE TWO ARE NEVER SUMMED — a plan's percentage is not money, and a provider's own spend is not a Hanzo charge. The rows sit side by side and say what they are. One resolver fixes the window for both halves, so the two sets always cover the same period. range is one of 1h, 24h, 7d or 30d and defaults to 24h; anything else is 400 rather than a silent substitution. A ledger that cannot answer reports available:false instead of a zero that would read as \"no usage\".
|
|
/// </remarks>
|
|
/// <param name="range">Range is the period, one of 1h, 24h, 7d or 30d; empty means 24h, and an unknown label is 400, never a silent substitution. (optional, default to utility::conversions::to_string_t(""))</param>
|
|
pplx::task<std::shared_ptr<SummaryResp>> getLinkUsageSummary(
|
|
boost::optional<utility::string_t> range
|
|
) const;
|
|
/// <summary>
|
|
/// Registers a signed-in AI provider account on a machine.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Registers a signed-in AI provider account on a machine. It records that a developer has signed into one provider account on one machine — a Claude Max or ChatGPT Plus subscription, a Hanzo key, a raw provider key — and answers 201 with the stored link. Re-reporting the same (machine, provider, account) UPDATES that link rather than creating a second, so a collector may call this on every heartbeat. machine and provider are required (400 otherwise), as is a valid kind, and every field is length-bounded. Scoped to the caller: a validated principal and a non-empty org, else 403, so a caller writes only their OWN accounts within their own org.
|
|
/// </remarks>
|
|
/// <param name="enrollReq"></param>
|
|
pplx::task<std::shared_ptr<LinkView>> postLink(
|
|
std::shared_ptr<EnrollReq> enrollReq
|
|
) const;
|
|
/// <summary>
|
|
/// Logs out every account on one machine and stops its sessions.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Logs out every account on one machine and stops its sessions. It revokes every one of the caller's accounts on one machine and stops the agent sessions they were running, answering with how many of each. This is the \"I lost that laptop\" button. Revoked links are RETAINED, not deleted, so usage history and the audit trail survive a log-out — the rows come back in the response with their new status. The session stop reaches only the REVOKING user's own sessions, so a shared machine name can never be used to stop a co-tenant's work, and a stop that fails does not fail the revoke: the revoked row is the durable truth and the count then honestly reports fewer. A machine with nothing left to revoke is 404.
|
|
/// </remarks>
|
|
/// <param name="machine">Machine is the machine to act on, from the path. It is scoped to the caller, so a machine with none of the caller's accounts is a 404.</param>
|
|
pplx::task<std::shared_ptr<RevokeResp>> postLinkDevicesByMachineRevoke(
|
|
utility::string_t machine
|
|
) const;
|
|
/// <summary>
|
|
/// Reports usage samples from the device collector.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Reports usage samples from the device collector. It ingests a batch of usage samples and answers with how many were accepted, whether history was durably stored, and the links they refreshed. A report also REFRESHES one link per distinct (machine, provider, account) it names, so a running collector keeps the accounts overview current without a separate registration call. A caller can only ever report for THEMSELVES: org and subject come from the validated bearer, never from the body, so no sample can be attributed to another user or tenant. History is FAIL-SOFT and stored says which happened — a warehouse outage still accepts the report and refreshes the links rather than failing the device, and answers 202 either way. Send either one sample inline or up to 256 in samples; an empty batch or an over-long one is 400, as is a provider, window class or kind outside the closed vocabulary — an unrecognized window is refused rather than rewritten, because a silently reclassified sample would fill a dashboard with a class nobody reported.
|
|
/// </remarks>
|
|
/// <param name="ingestReq"></param>
|
|
pplx::task<std::shared_ptr<IngestResp>> postLinkUsage(
|
|
std::shared_ptr<IngestReq> ingestReq
|
|
) const;
|
|
|
|
protected:
|
|
std::shared_ptr<const ApiClient> m_ApiClient;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif /* HANZO_API_LinkApi_H_ */
|
|
|