lib.rsannotatedlib.rssource40 lines · 1.8 kB · raw

Google Compute Engine as a cloud_mock::World: instances, zone operations that finish on a virtual clock, snapshots, labels and list filters, paging and the OAuth token endpoint, behaving the way the documentation says, with every answer checked against Google's own discovery document (spec/compute-v1.discovery.json, pinned; spec/SOURCE.md says where and when).

let mock = cloud_mock_gcp::mock("my-project");          // checked against the document
let gcp = sandbox_gcp::Gcp::new(mock.io(), GcpConfig::new("my-project"), Credentials::AccessToken(DEFAULT_TOKEN.into()));
// ... drive the adapter; its sleeps move the world's clock ...
mock.assert_conforms();

What is modelled: instances (insert from an image or a snapshot, get, list with filter, maxResults and pageToken, delete, start, stop with and without the graceful shutdown, reset, setLabels), zone and global operations (get, list, wait, delete), boot disks and disks.createSnapshot, snapshots (list, get, delete), zones, machine types, public images, the token endpoint (refresh token and JWT bearer grants), bearer authentication with expiry, a request limit, and the error envelope. Everything else answers 501, naming the operation.

20mod auth;
21mod catalog;
22mod errors;
23mod filter;
24mod instances;
25mod list;
26mod attach;
27mod disks;
28mod generic;
29mod ops;
30mod snapshots;
31mod spec;
32mod world;
34pub use filter::{Expr, matches as filter_matches, parse as parse_filter};
35pub use ops::OpError;
36pub use spec::{BASE_PATH, GcpChecker, SPEC_TEXT, TOKEN_PATH, contract, openapi_of, spec};
37pub use world::{Config, DEFAULT_CLIENT_ID, DEFAULT_CLIENT_SECRET, DEFAULT_PROJECT, DEFAULT_REFRESH_TOKEN, DEFAULT_SERVICE_ACCOUNT, DEFAULT_TOKEN, GcpWorld, mock};
38
39#[cfg(test)]
40mod tests;