跳转到内容
EN

Read a target's OpenTofu state

Code Mode: praxis.devops.projects.environments.targets.retrieveState

HTTP: GET /devops/v1/projects/{project}/environments/{environment}/targets/{target}/state

Read the current OpenTofu state of one deploy target in one DevOps environment. This is the read half of the OpenTofu HTTP backend that praxis devops deploy --engine tofu configures: OpenTofu sends HTTP Basic with any username and a Praxis API key as the password, and the route accepts the ordinary Bearer key too. The answer is the state document exactly as the last write stored it. A target never deployed in this environment answers 404, which OpenTofu reads as an empty state.

签名

praxis.devops.projects.environments.targets.retrieveState(args:{path:{/** e.g. "dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ project:string;/** e.g. "dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ environment:string;/** e.g. "services%2Fontology" */ target:string}}):Promise<{/** The state format version OpenTofu wrote. e.g. 4 */ version?:number;/** Increases with every state change; a write lower than the stored serial of the same lineage is refused as stale. e.g. 12 */ serial:number;/** Identifies one state history; it does not change across writes. e.g. "7b2c1e9a-3d4f-8a6b-5c7d-9e0f1a2b3c4d" */ lineage:string;[key:string]:unknown}>;

参数

名称位置类型必填说明
projectpathstring是Identifies the project whose data you are reading, from the project list or create answer.
environmentpathstring是Identifies the DevOps environment (dve_…) whose deploy state you address, from the project’s environment list.
targetpathstring是The deploy target’s repository path, URL-encoded as one segment: services/ontology is written services%2Fontology.

响应

状态码内容类型说明
200application/jsonThe current state document, byte for byte as the last write stored it.
401application/jsonThe API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying.
404application/jsonNOT_FOUND means the project or environment does not exist for this organization, or, on a read, that the target has no state yet. Nothing is revealed about another organization’s projects. OpenTofu reads a missing state as empty.
500application/jsonINTERNAL means the service could not complete the request; retry once, and if it repeats report the request id. A read is safe to repeat; a write that failed this way should be re-read before it is sent again.