maproom 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. maproom/__init__.py +14 -0
  2. maproom/__main__.py +10 -0
  3. maproom/analyze/__init__.py +1 -0
  4. maproom/analyze/accel_families.py +45 -0
  5. maproom/analyze/account_azure_activity.py +260 -0
  6. maproom/analyze/account_azure_quota_requests.py +177 -0
  7. maproom/analyze/account_cloudtrail.py +316 -0
  8. maproom/analyze/account_quota_requests.py +180 -0
  9. maproom/analyze/analyze_v1_orchestration.py +1194 -0
  10. maproom/analyze/catalog.py +353 -0
  11. maproom/analyze/change_detection.py +652 -0
  12. maproom/analyze/context_client.py +99 -0
  13. maproom/analyze/context_lookup.py +142 -0
  14. maproom/analyze/cover_analyze.py +344 -0
  15. maproom/analyze/cover_client.py +65 -0
  16. maproom/analyze/cover_lookup.py +242 -0
  17. maproom/analyze/engine.py +644 -0
  18. maproom/analyze/fleetfit_endpoints.py +217 -0
  19. maproom/analyze/fleetfit_policy.py +66 -0
  20. maproom/analyze/instance_price_analyze.py +221 -0
  21. maproom/analyze/instance_price_client.py +108 -0
  22. maproom/analyze/instance_price_lookup.py +60 -0
  23. maproom/analyze/local_reads.py +484 -0
  24. maproom/analyze/lookup_http.py +280 -0
  25. maproom/analyze/metric_format.py +20 -0
  26. maproom/analyze/migration_method.py +130 -0
  27. maproom/analyze/move_list.py +93 -0
  28. maproom/analyze/operator_context.py +156 -0
  29. maproom/analyze/performance_rank.py +97 -0
  30. maproom/analyze/primary_recommendation.py +422 -0
  31. maproom/analyze/provider_comparison.py +401 -0
  32. maproom/analyze/quota_analyze.py +481 -0
  33. maproom/analyze/quota_client.py +75 -0
  34. maproom/analyze/quota_lookup.py +110 -0
  35. maproom/analyze/quota_outcome_steer.py +105 -0
  36. maproom/analyze/recommend_batch.py +199 -0
  37. maproom/analyze/recommend_client.py +362 -0
  38. maproom/analyze/recommend_share.py +118 -0
  39. maproom/analyze/recommendation.py +591 -0
  40. maproom/analyze/reservation_pack.py +883 -0
  41. maproom/analyze/reservation_read.py +461 -0
  42. maproom/analyze/safe_analyze.py +1134 -0
  43. maproom/analyze/safe_move.py +195 -0
  44. maproom/analyze/safe_moves.py +571 -0
  45. maproom/analyze/safe_moves_catalog.py +127 -0
  46. maproom/analyze/safe_moves_client.py +70 -0
  47. maproom/analyze/series_analyze.py +491 -0
  48. maproom/analyze/series_client.py +106 -0
  49. maproom/analyze/series_lookup.py +663 -0
  50. maproom/analyze/shape.py +254 -0
  51. maproom/analyze/size_analyze.py +883 -0
  52. maproom/analyze/size_client.py +81 -0
  53. maproom/analyze/size_keep.py +409 -0
  54. maproom/analyze/size_lookup.py +368 -0
  55. maproom/analyze/specs.py +325 -0
  56. maproom/analyze/spot_analyze.py +392 -0
  57. maproom/analyze/spot_client.py +74 -0
  58. maproom/analyze/spot_lookup.py +213 -0
  59. maproom/analyze/token_client.py +97 -0
  60. maproom/analyze/utilization.py +190 -0
  61. maproom/analyze/workload.py +104 -0
  62. maproom/analyze/workset.py +762 -0
  63. maproom/aws_region.py +78 -0
  64. maproom/cache/__init__.py +1 -0
  65. maproom/cache/catalog.py +372 -0
  66. maproom/cache/commands.py +215 -0
  67. maproom/cache/instances.py +460 -0
  68. maproom/cli.py +2084 -0
  69. maproom/cli_argv.py +329 -0
  70. maproom/cli_floors.py +89 -0
  71. maproom/cliio/__init__.py +1 -0
  72. maproom/cliio/registry.py +377 -0
  73. maproom/cliio/runner.py +489 -0
  74. maproom/consent/__init__.py +33 -0
  75. maproom/consent/gate.py +238 -0
  76. maproom/consent/policy.py +20 -0
  77. maproom/consent/prompt.py +61 -0
  78. maproom/consent/service_upload_gate.py +318 -0
  79. maproom/consent/service_upload_prompt.py +62 -0
  80. maproom/consent/stdin.py +45 -0
  81. maproom/consent/storage.py +24 -0
  82. maproom/consent/write_token.py +29 -0
  83. maproom/contracts/__init__.py +6 -0
  84. maproom/contracts/schema_diff.py +119 -0
  85. maproom/contracts/validate.py +113 -0
  86. maproom/data/__init__.py +1 -0
  87. maproom/data/clear.py +76 -0
  88. maproom/data/commands.py +14 -0
  89. maproom/doctor/__init__.py +1 -0
  90. maproom/doctor/aws_session.py +226 -0
  91. maproom/doctor/checks.py +701 -0
  92. maproom/doctor/context.py +32 -0
  93. maproom/doctor/display.py +96 -0
  94. maproom/doctor/inventory_display.py +377 -0
  95. maproom/doctor/runner.py +1467 -0
  96. maproom/errors.py +43 -0
  97. maproom/exitcodes.py +70 -0
  98. maproom/inventory/__init__.py +1 -0
  99. maproom/inventory/account_identity.py +79 -0
  100. maproom/inventory/accounts.py +155 -0
  101. maproom/inventory/command.py +961 -0
  102. maproom/inventory/messages.py +264 -0
  103. maproom/inventory/reservations_refresh.py +37 -0
  104. maproom/mock_environment/__init__.py +28 -0
  105. maproom/mock_environment/load.py +241 -0
  106. maproom/mock_environment/runner.py +387 -0
  107. maproom/output/__init__.py +1 -0
  108. maproom/output/json_envelope.py +241 -0
  109. maproom/output/redact.py +11 -0
  110. maproom/output/terminal.py +129 -0
  111. maproom/parsers.py +284 -0
  112. maproom/paths.py +105 -0
  113. maproom/plan/__init__.py +1 -0
  114. maproom/plan/accept.py +59 -0
  115. maproom/plan/analysis_context.py +78 -0
  116. maproom/plan/analyze_selection.py +279 -0
  117. maproom/plan/commands.py +586 -0
  118. maproom/plan/current.py +59 -0
  119. maproom/plan/errors.py +10 -0
  120. maproom/plan/export.py +36 -0
  121. maproom/plan/formatting.py +91 -0
  122. maproom/plan/ids.py +13 -0
  123. maproom/plan/migration_options.py +75 -0
  124. maproom/plan/model.py +265 -0
  125. maproom/plan/names.py +24 -0
  126. maproom/plan/store.py +193 -0
  127. maproom/plan/tty.py +34 -0
  128. maproom/pricing/__init__.py +5 -0
  129. maproom/pricing/prices.py +119 -0
  130. maproom/privacy/__init__.py +6 -0
  131. maproom/privacy/commands.py +159 -0
  132. maproom/privacy/delete_uploads.py +204 -0
  133. maproom/privacy/fleetfit_policy.py +125 -0
  134. maproom/privacy/fleetfit_statement.py +104 -0
  135. maproom/privacy/format.py +76 -0
  136. maproom/privacy/manifests.py +342 -0
  137. maproom/privacy/statement.py +58 -0
  138. maproom/quotas/__init__.py +21 -0
  139. maproom/quotas/aws.py +204 -0
  140. maproom/quotas/azure.py +75 -0
  141. maproom/quotas/commands.py +240 -0
  142. maproom/quotas/family_coverage.py +122 -0
  143. maproom/quotas/fetch.py +124 -0
  144. maproom/quotas/load.py +41 -0
  145. maproom/quotas/model.py +178 -0
  146. maproom/quotas/outcome_ledger.py +245 -0
  147. maproom/quotas/quota_request_sync.py +221 -0
  148. maproom/quotas/show.py +73 -0
  149. maproom/quotas/status.py +206 -0
  150. maproom/quotas/store.py +161 -0
  151. maproom/redaction.py +157 -0
  152. maproom/reference_data/__init__.py +1 -0
  153. maproom/reference_data/aws/aws_prices.csv +25562 -0
  154. maproom/reference_data/aws/capabilities.csv +1346 -0
  155. maproom/reference_data/aws/instance_types.csv +1346 -0
  156. maproom/reference_data/azure/azure_prices.csv +1 -0
  157. maproom/reference_data/azure/vm_types.csv +1 -0
  158. maproom/reference_data/benchmarks/cpu-lscpu-v2-instances.json +27 -0
  159. maproom/reference_data/benchmarks/safe-moves-v1.json +328 -0
  160. maproom/reference_data/manifest.json +174 -0
  161. maproom/reference_data/manifest.py +69 -0
  162. maproom/reservations/__init__.py +17 -0
  163. maproom/reservations/aws.py +76 -0
  164. maproom/reservations/azure.py +36 -0
  165. maproom/reservations/commands.py +149 -0
  166. maproom/reservations/load.py +41 -0
  167. maproom/reservations/model.py +316 -0
  168. maproom/reservations/show.py +64 -0
  169. maproom/reservations/status.py +181 -0
  170. maproom/reservations/store.py +391 -0
  171. maproom/resources.py +54 -0
  172. maproom/root_help.py +251 -0
  173. maproom/saving_plans/__init__.py +15 -0
  174. maproom/saving_plans/aws.py +73 -0
  175. maproom/saving_plans/commands.py +122 -0
  176. maproom/saving_plans/load.py +41 -0
  177. maproom/saving_plans/model.py +101 -0
  178. maproom/saving_plans/show.py +64 -0
  179. maproom/saving_plans/status.py +118 -0
  180. maproom/saving_plans/store.py +173 -0
  181. maproom/secret_egress_gate.py +108 -0
  182. maproom/service/install_id.py +60 -0
  183. maproom/settings/__init__.py +1 -0
  184. maproom/settings/defaults.py +73 -0
  185. maproom/settings/init.py +143 -0
  186. maproom/settings/model.py +105 -0
  187. maproom/settings/product_version_change.py +343 -0
  188. maproom/settings/product_versions.py +68 -0
  189. maproom/settings/set.py +347 -0
  190. maproom/settings/show.py +227 -0
  191. maproom/settings/write.py +273 -0
  192. maproom/snapshot_time.py +27 -0
  193. maproom-0.2.0.dist-info/METADATA +263 -0
  194. maproom-0.2.0.dist-info/RECORD +199 -0
  195. maproom-0.2.0.dist-info/WHEEL +5 -0
  196. maproom-0.2.0.dist-info/entry_points.txt +2 -0
  197. maproom-0.2.0.dist-info/licenses/LICENSE +201 -0
  198. maproom-0.2.0.dist-info/licenses/NOTICE +72 -0
  199. maproom-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,377 @@
1
+ """Closed catalog of AWS and Azure CLI calls Maproom is allowed to make.
2
+
3
+ Every ``Runner.run`` call must name an entry here. Privacy manifests derive
4
+ their operation lists from this catalog, so a new call cannot ship without
5
+ showing up in ``maproom privacy``.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import hashlib
11
+ import json
12
+ from dataclasses import dataclass
13
+ from typing import Literal, Sequence
14
+
15
+ CloudName = Literal["aws", "azure"]
16
+ Access = Literal["read", "write", "local"]
17
+ Consent = Literal["cloud-read", "cloud-write", "none"]
18
+
19
+
20
+ class UnregisteredApiError(Exception):
21
+ """A cloud CLI call is not in the registered catalog, or a write lacks consent."""
22
+
23
+
24
+ @dataclass(frozen=True)
25
+ class ApiEntry:
26
+ api_id: str
27
+ cloud: CloudName
28
+ argv_prefix: tuple[str, ...]
29
+ operation: str
30
+ access: Access
31
+ consent: Consent
32
+ features: tuple[str, ...]
33
+ purpose: str
34
+
35
+
36
+ REGISTRY: tuple[ApiEntry, ...] = (
37
+ ApiEntry(
38
+ api_id="aws_sts_get_caller_identity",
39
+ cloud="aws",
40
+ argv_prefix=("sts", "get-caller-identity"),
41
+ operation="sts:GetCallerIdentity",
42
+ access="read",
43
+ consent="cloud-read",
44
+ features=("analyze", "doctor", "inventory"),
45
+ purpose="Verify the logged-in AWS identity",
46
+ ),
47
+ ApiEntry(
48
+ api_id="aws_iam_list_account_aliases",
49
+ cloud="aws",
50
+ argv_prefix=("iam", "list-account-aliases"),
51
+ operation="iam:ListAccountAliases",
52
+ access="read",
53
+ consent="cloud-read",
54
+ features=("inventory",),
55
+ purpose="Read the IAM account alias used in the local data folder name",
56
+ ),
57
+ ApiEntry(
58
+ api_id="aws_ec2_describe_instances",
59
+ cloud="aws",
60
+ argv_prefix=("ec2", "describe-instances"),
61
+ operation="ec2:DescribeInstances",
62
+ access="read",
63
+ consent="cloud-read",
64
+ features=("analyze",),
65
+ purpose="Read the target EC2 instance",
66
+ ),
67
+ ApiEntry(
68
+ api_id="aws_cloudwatch_get_metric_data",
69
+ cloud="aws",
70
+ argv_prefix=("cloudwatch", "get-metric-data"),
71
+ operation="cloudwatch:GetMetricData",
72
+ access="read",
73
+ consent="cloud-read",
74
+ features=("analyze",),
75
+ purpose="Read EC2 CPU utilization",
76
+ ),
77
+ ApiEntry(
78
+ api_id="aws_cloudwatch_usage_get_metric_data",
79
+ cloud="aws",
80
+ argv_prefix=("cloudwatch", "get-metric-data"),
81
+ operation="cloudwatch:GetMetricData (AWS/Usage quota usage)",
82
+ access="read",
83
+ consent="cloud-read",
84
+ features=("inventory",),
85
+ purpose="Read EC2 quota usage from AWS/Usage",
86
+ ),
87
+ ApiEntry(
88
+ api_id="aws_compute_optimizer_get_ec2_instance_recommendations",
89
+ cloud="aws",
90
+ argv_prefix=("compute-optimizer", "get-ec2-instance-recommendations"),
91
+ operation="compute-optimizer:GetEC2InstanceRecommendations",
92
+ access="read",
93
+ consent="cloud-read",
94
+ features=("analyze",),
95
+ purpose="Read Compute Optimizer rightsizing recommendations",
96
+ ),
97
+ ApiEntry(
98
+ api_id="aws_cloudtrail_lookup_events",
99
+ cloud="aws",
100
+ argv_prefix=("cloudtrail", "lookup-events"),
101
+ operation="cloudtrail:LookupEvents",
102
+ access="read",
103
+ consent="cloud-read",
104
+ features=("analyze",),
105
+ purpose="Look for a recent instance type change",
106
+ ),
107
+ ApiEntry(
108
+ api_id="aws_config_get_resource_config_history",
109
+ cloud="aws",
110
+ argv_prefix=("configservice", "get-resource-config-history"),
111
+ operation="config:GetResourceConfigHistory",
112
+ access="read",
113
+ consent="cloud-read",
114
+ features=("analyze",),
115
+ purpose="Read AWS Config history for an instance type change",
116
+ ),
117
+ ApiEntry(
118
+ api_id="aws_ec2_describe_reserved_instances",
119
+ cloud="aws",
120
+ argv_prefix=("ec2", "describe-reserved-instances"),
121
+ operation="ec2:DescribeReservedInstances",
122
+ access="read",
123
+ consent="cloud-read",
124
+ features=("analyze", "inventory"),
125
+ purpose="Read EC2 Reserved Instances in the region",
126
+ ),
127
+ ApiEntry(
128
+ api_id="aws_ce_get_reservation_utilization",
129
+ cloud="aws",
130
+ argv_prefix=("ce", "get-reservation-utilization"),
131
+ operation="ce:GetReservationUtilization",
132
+ access="read",
133
+ consent="cloud-read",
134
+ features=("analyze",),
135
+ purpose="Read EC2 Reserved Instance utilization for analyze version 4",
136
+ ),
137
+ ApiEntry(
138
+ api_id="aws_savingsplans_describe_savings_plans",
139
+ cloud="aws",
140
+ argv_prefix=("savingsplans", "describe-savings-plans"),
141
+ operation="savingsplans:DescribeSavingsPlans",
142
+ access="read",
143
+ consent="cloud-read",
144
+ features=("inventory",),
145
+ purpose="Read Savings Plans in the account",
146
+ ),
147
+ ApiEntry(
148
+ api_id="aws_service_quotas_list_service_quotas",
149
+ cloud="aws",
150
+ argv_prefix=("service-quotas", "list-service-quotas"),
151
+ operation="servicequotas:ListServiceQuotas",
152
+ access="read",
153
+ consent="cloud-read",
154
+ features=("inventory",),
155
+ purpose="Read EC2 service quotas",
156
+ ),
157
+ ApiEntry(
158
+ api_id="aws_configure_get_region",
159
+ cloud="aws",
160
+ argv_prefix=("configure", "get", "region"),
161
+ operation="aws configure get region",
162
+ access="local",
163
+ consent="none",
164
+ features=("analyze", "inventory"),
165
+ purpose="Read the local AWS CLI default region; no network call",
166
+ ),
167
+ ApiEntry(
168
+ api_id="azure_account_show",
169
+ cloud="azure",
170
+ argv_prefix=("account", "show"),
171
+ operation="az account show",
172
+ access="read",
173
+ consent="cloud-read",
174
+ features=("doctor", "inventory"),
175
+ purpose="Verify the logged-in Azure account",
176
+ ),
177
+ ApiEntry(
178
+ api_id="azure_vm_list_usage",
179
+ cloud="azure",
180
+ argv_prefix=("vm", "list-usage"),
181
+ operation="az vm list-usage",
182
+ access="read",
183
+ consent="cloud-read",
184
+ features=("inventory",),
185
+ purpose="Read regional VM usage and quota limits",
186
+ ),
187
+ ApiEntry(
188
+ api_id="azure_configure_get_location",
189
+ cloud="azure",
190
+ argv_prefix=("config", "get", "defaults.location"),
191
+ operation="az config get defaults.location",
192
+ access="local",
193
+ consent="none",
194
+ features=("inventory",),
195
+ purpose="Read the local Azure CLI default location; no network call",
196
+ ),
197
+ ApiEntry(
198
+ api_id="azure_vm_list",
199
+ cloud="azure",
200
+ argv_prefix=("vm", "list"),
201
+ operation="az vm list -d",
202
+ access="read",
203
+ consent="cloud-read",
204
+ features=("analyze",),
205
+ purpose="List Azure virtual machines",
206
+ ),
207
+ ApiEntry(
208
+ api_id="azure_network_nic_show",
209
+ cloud="azure",
210
+ argv_prefix=("network", "nic", "show"),
211
+ operation="az network nic show",
212
+ access="read",
213
+ consent="cloud-read",
214
+ features=("analyze",),
215
+ purpose="Read whether a NIC has accelerated networking",
216
+ ),
217
+ ApiEntry(
218
+ api_id="azure_reservations_list",
219
+ cloud="azure",
220
+ argv_prefix=("reservations", "list"),
221
+ operation="az reservations list",
222
+ access="read",
223
+ consent="cloud-read",
224
+ features=("analyze",),
225
+ purpose="List Azure reserved VM instances for version 4 analyze",
226
+ ),
227
+ ApiEntry(
228
+ api_id="azure_monitor_activity_log_list",
229
+ cloud="azure",
230
+ argv_prefix=("monitor", "activity-log", "list"),
231
+ operation="az monitor activity-log list",
232
+ access="read",
233
+ consent="cloud-read",
234
+ features=("analyze",),
235
+ purpose="Read VM writes and Spot evictions for product_version 3+ account context",
236
+ ),
237
+ ApiEntry(
238
+ api_id="azure_quota_request_list",
239
+ cloud="azure",
240
+ argv_prefix=("quota", "request", "list"),
241
+ operation="az quota request list",
242
+ access="read",
243
+ consent="cloud-read",
244
+ features=("analyze",),
245
+ purpose="Read compute quota increase history for product_version 6 account context",
246
+ ),
247
+ ApiEntry(
248
+ api_id="aws_cli_version",
249
+ cloud="aws",
250
+ argv_prefix=("--version",),
251
+ operation="aws --version",
252
+ access="local",
253
+ consent="none",
254
+ features=("doctor",),
255
+ purpose="Read the local AWS CLI version; no cloud account call",
256
+ ),
257
+ ApiEntry(
258
+ api_id="azure_cli_version",
259
+ cloud="azure",
260
+ argv_prefix=("version",),
261
+ operation="az version",
262
+ access="local",
263
+ consent="none",
264
+ features=("doctor",),
265
+ purpose="Read the local Azure CLI version; no cloud account call",
266
+ ),
267
+ ApiEntry(
268
+ api_id="aws_service_quotas_get_requested_service_quota_change",
269
+ cloud="aws",
270
+ argv_prefix=("service-quotas", "get-requested-service-quota-change"),
271
+ operation="servicequotas:GetRequestedServiceQuotaChange",
272
+ access="read",
273
+ consent="cloud-read",
274
+ features=("analyze",),
275
+ purpose="Read terminal EC2 quota increase outcomes for product_version 7 steering",
276
+ ),
277
+ ApiEntry(
278
+ api_id="aws_service_quotas_list_requested_service_quota_change_history",
279
+ cloud="aws",
280
+ argv_prefix=(
281
+ "service-quotas",
282
+ "list-requested-service-quota-change-history",
283
+ ),
284
+ operation="servicequotas:ListRequestedServiceQuotaChangeHistory",
285
+ access="read",
286
+ consent="cloud-read",
287
+ features=("analyze",),
288
+ purpose="Read EC2 quota increase history for product_version 6 account context",
289
+ ),
290
+ ApiEntry(
291
+ api_id="aws_service_quotas_request_service_quota_increase",
292
+ cloud="aws",
293
+ argv_prefix=("service-quotas", "request-service-quota-increase"),
294
+ operation="servicequotas:RequestServiceQuotaIncrease",
295
+ access="write",
296
+ consent="cloud-write",
297
+ features=("analyze",),
298
+ purpose="Submit an operator-approved EC2 quota increase during analyze version 6",
299
+ ),
300
+ ApiEntry(
301
+ api_id="aws_support_create_case",
302
+ cloud="aws",
303
+ argv_prefix=("support", "create-case"),
304
+ operation="support:CreateCase",
305
+ access="write",
306
+ consent="cloud-write",
307
+ features=("analyze",),
308
+ purpose="Open a support case after a declined quota increase during analyze version 6",
309
+ ),
310
+ )
311
+
312
+ _BY_ID: dict[str, ApiEntry] = {entry.api_id: entry for entry in REGISTRY}
313
+
314
+
315
+ def get(api_id: str) -> ApiEntry | None:
316
+ return _BY_ID.get(api_id)
317
+
318
+
319
+ def entries_for(feature: str) -> tuple[ApiEntry, ...]:
320
+ return tuple(entry for entry in REGISTRY if feature in entry.features)
321
+
322
+
323
+ def registry_sha256() -> str:
324
+ payload = [
325
+ {
326
+ "api_id": entry.api_id,
327
+ "cloud": entry.cloud,
328
+ "argv_prefix": list(entry.argv_prefix),
329
+ "operation": entry.operation,
330
+ "access": entry.access,
331
+ "consent": entry.consent,
332
+ "features": list(entry.features),
333
+ "purpose": entry.purpose,
334
+ }
335
+ for entry in REGISTRY
336
+ ]
337
+ encoded = json.dumps(payload, sort_keys=True, separators=(",", ":")).encode("utf-8")
338
+ return hashlib.sha256(encoded).hexdigest()
339
+
340
+
341
+ def authorize_cli_call(
342
+ cloud: str,
343
+ argv: Sequence[str],
344
+ api_id: str,
345
+ *,
346
+ write_token: str | None = None,
347
+ ) -> ApiEntry:
348
+ """Reject any cloud CLI invocation that is not the registered command.
349
+
350
+ Write calls also require a one-time token from ``issue_cloud_write_token``,
351
+ which only the consent path may mint.
352
+ """
353
+ entry = _BY_ID.get(api_id)
354
+ if entry is None:
355
+ known = ", ".join(sorted(_BY_ID))
356
+ raise UnregisteredApiError(
357
+ f"unregistered api_id {api_id!r}. Registered APIs: {known}"
358
+ )
359
+ if cloud != entry.cloud:
360
+ raise UnregisteredApiError(
361
+ f"{api_id} is registered for {entry.cloud}, not {cloud!r}"
362
+ )
363
+ prefix = entry.argv_prefix
364
+ if tuple(argv[: len(prefix)]) != prefix:
365
+ rendered = " ".join(prefix)
366
+ raise UnregisteredApiError(
367
+ f"{api_id} must start with {rendered!r}; got {list(argv)!r}"
368
+ )
369
+ if entry.access == "write":
370
+ from maproom.consent.write_token import consume_cloud_write_token
371
+
372
+ if not consume_cloud_write_token(api_id, write_token):
373
+ raise UnregisteredApiError(
374
+ f"{api_id} is a write. It requires a write token issued after "
375
+ "the operator approves that exact request."
376
+ )
377
+ return entry